From 80cb3f595447a19b560938b7d9a4e1c09e84d8a7 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 16 Mar 2023 08:06:39 +0100 Subject: [PATCH] Fix DI logic when mailer is available but webhook is not --- .../DependencyInjection/FrameworkExtension.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 8cb557fb7d35d..35ca155fd7a7e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -2527,16 +2527,18 @@ private function registerMailerConfiguration(array $config, ContainerBuilder $co } } - $webhookRequestParsers = [ - MailgunRequestParser::class => 'mailer.webhook.request_parser.mailgun', - PostmarkRequestParser::class => 'mailer.webhook.request_parser.postmark', - ]; + if ($webhookEnabled) { + $webhookRequestParsers = [ + MailgunRequestParser::class => 'mailer.webhook.request_parser.mailgun', + PostmarkRequestParser::class => 'mailer.webhook.request_parser.postmark', + ]; - foreach ($webhookRequestParsers as $class => $service) { - $package = substr($service, \strlen('mailer.transport_factory.')); + foreach ($webhookRequestParsers as $class => $service) { + $package = substr($service, \strlen('mailer.transport_factory.')); - if (!ContainerBuilder::willBeAvailable(sprintf('symfony/%s-mailer', 'gmail' === $package ? 'google' : $package), $class, ['symfony/framework-bundle', 'symfony/mailer'])) { - $container->removeDefinition($service); + if (!ContainerBuilder::willBeAvailable(sprintf('symfony/%s-mailer', 'gmail' === $package ? 'google' : $package), $class, ['symfony/framework-bundle', 'symfony/mailer'])) { + $container->removeDefinition($service); + } } }