From 4dd82d049b263a0c4f89a8b8dc98466e8c72e0bd Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 24 Oct 2019 22:33:05 +0200 Subject: [PATCH] [Notifier] Disable notifications on failed messages by default --- .../FrameworkBundle/DependencyInjection/Configuration.php | 1 + .../DependencyInjection/FrameworkExtension.php | 8 +++++--- .../Bundle/FrameworkBundle/Resources/config/notifier.xml | 1 - 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 6e20173a4c..e66061440b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -1516,6 +1516,7 @@ class Configuration implements ConfigurationInterface ->prototype('scalar')->end() ->end() ->end() + ->booleanNode('notification_on_failed_messages')->defaultFalse()->end() ->children() ->arrayNode('channel_policy') ->useAttributeAsKey('name') diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 64b0bfbd2d..2fe3a22a59 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -1934,9 +1934,11 @@ class FrameworkExtension extends Extension $container->removeDefinition('notifier.channel.email'); } - if (!$this->messengerConfigEnabled) { - $container->removeDefinition('notifier.failed_message_listener'); - } else { + if ($this->messengerConfigEnabled) { + if ($config['notification_on_failed_messages']) { + $container->getDefinition('notifier.failed_message_listener')->addTag('kernel.event_subscriber'); + } + // as we have a bus, the channels don't need the transports $container->getDefinition('notifier.channel.chat')->setArgument(0, null); $container->getDefinition('notifier.channel.email')->setArgument(0, null); diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier.xml index 749fb770e2..dfc6cdccd3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier.xml @@ -44,7 +44,6 @@ -