Skip to content

[FrameworkBundle] do not use deprecated mailer.logger_message_listener service #37728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1990,6 +1990,9 @@ private function registerMailerConfiguration(array $config, ContainerBuilder $co
$container->getDefinition('mailer.transports')->setArgument(0, $transports);
$container->getDefinition('mailer.default_transport')->setArgument(0, current($transports));

$container->removeDefinition('mailer.logger_message_listener');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why removing a definition and adding a deprecated alias following it ? Why not creating the right deprecated alias from the beginning ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mailer.message_logger_listener service is not always defined (only when the profiler is enabled).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but here, you still remove the mailer.logger_message_listener definition all the time to replace it by an alias. So I don't see how this matters.

$container->setAlias('mailer.logger_message_listener', (new Alias('mailer.message_logger_listener'))->setDeprecated('symfony/framework-bundle', '5.2', 'The "%alias_id%" alias is deprecated, use "mailer.message_logger_listener" instead.'));

$mailer = $container->getDefinition('mailer.mailer');
if (false === $messageBus = $config['message_bus']) {
$mailer->replaceArgument(1, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public static function getMailerMessage(int $index = 0, string $transport = null

private static function getMessageMailerEvents(): MessageEvents
{
if (!self::$container->has('mailer.logger_message_listener')) {
if (!(self::$container->has('mailer.message_logger_listener') ? self::$container->get('mailer.message_logger_listener') : self::$container->get('mailer.logger_message_listener'))) {
static::fail('A client must have Mailer enabled to make email assertions. Did you forget to require symfony/mailer?');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ framework:
sender: sender@example.org
recipients:
- redirected@example.org
profiler: ~