Skip to content

Commit e867132

Browse files
committed
[Notifier] Disable notifications on failed messages by default
1 parent 19b8558 commit e867132

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

DependencyInjection/Configuration.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,6 +1516,7 @@ private function addNotifierSection(ArrayNodeDefinition $rootNode)
15161516
->prototype('scalar')->end()
15171517
->end()
15181518
->end()
1519+
->booleanNode('notification_on_failed_messages')->defaultFalse()->end()
15191520
->children()
15201521
->arrayNode('channel_policy')
15211522
->useAttributeAsKey('name')

DependencyInjection/FrameworkExtension.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1934,9 +1934,11 @@ private function registerNotifierConfiguration(array $config, ContainerBuilder $
19341934
$container->removeDefinition('notifier.channel.email');
19351935
}
19361936

1937-
if (!$this->messengerConfigEnabled) {
1938-
$container->removeDefinition('notifier.failed_message_listener');
1939-
} else {
1937+
if ($this->messengerConfigEnabled) {
1938+
if ($config['notification_on_failed_messages']) {
1939+
$container->getDefinition('notifier.failed_message_listener')->addTag('kernel.event_subscriber');
1940+
}
1941+
19401942
// as we have a bus, the channels don't need the transports
19411943
$container->getDefinition('notifier.channel.chat')->setArgument(0, null);
19421944
$container->getDefinition('notifier.channel.email')->setArgument(0, null);

Resources/config/notifier.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444

4545
<service id="notifier.failed_message_listener" class="Symfony\Component\Notifier\EventListener\SendFailedMessageToNotifierListener">
4646
<argument type="service" id="notifier" />
47-
<tag name="kernel.event_subscriber" />
4847
</service>
4948

5049
<!-- chatter -->

0 commit comments

Comments
 (0)