Skip to content

[Notifier] Add easier way to remove Importance from EmailNotification Subject #37879

Closed
@alexander-schranz

Description

@alexander-schranz

Description

When using the notifier the subject contains priority. I think in most cases you don't want to have the priority in the subject of the email (its not translated and contains maybe information not needed for the end user). So it would be great that we maybe could change this behaviour for the next major release, not sure if there could be a way to implement this now.

$headers->setHeaderBody('Text', 'Subject', sprintf('[%s] %s', strtoupper($importance), $this->getSubject()));

In the future I would maybe think that in the subject could be used a placeholder if somebody really wanted to have the priority in it but I personally see no advantage of it.

Example

This is how it could look in future to set a subject with importance:

use Symfony\Bridge\Twig\Mime\NotificationEmail;

$email = (new NotificationEmail())
    ->importance(NotificationEmail::IMPORTANCE_HIGH)
    ->subject('[%importance%] My Subject');

Current Workaround

At current state you need to implement your own NotificationEmail class to override this behaviour:

namespace App\Checkin\Application\Notifications;

use Symfony\Bridge\Twig\Mime\NotificationEmail;
use Symfony\Component\Mime\Header\Headers;

class CustomNotificationEmail extends NotificationEmail
{
    public function getPreparedHeaders(): Headers
    {
        $headers = parent::getPreparedHeaders();

        $headers->setHeaderBody('Text', 'Subject', $this->getSubject());

        return $headers;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions