8000 [FrameworkBundle][Notifier] Allow to configure or disable the message bus to use by jschaedl · Pull Request #39353 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[FrameworkBundle][Notifier] Allow to configure or disable the message bus to use #39353

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 2 commits into from
Dec 11, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Fix logic and tests
  • Loading branch information
fabpot authored and jschaedl committed Nov 9, 2022
commit fc7aaa6123c3e0cf4543bb3faeb65cbde26112bc
B1D2
Original file line number Diff line number Diff line change
Expand Up @@ -2522,6 +2522,18 @@ private function registerNotifierConfiguration(array $config, ContainerBuilder $
$container->removeDefinition('notifier.channel.email');
}

foreach (['texter', 'chatter', 'notifier.channel.chat', 'notifier.channel.email', 'notifier.channel.sms'] as $serviceId) {
if (!$container->hasDefinition($serviceId)) {
continue;
}

if (false === $messageBus = $config['message_bus']) {
$container->getDefinition($serviceId)->replaceArgument(1, null);
} else {
$container->getDefinition($serviceId)->replaceArgument(1, $messageBus ? new Reference($messageBus) : new Reference('messenger.default_bus', ContainerInterface::NULL_ON_INVALID_REFERENCE));
}
}

if ($this->isInitializedConfigEnabled('messenger')) {
if ($config['notification_on_failed_messages']) {
$container->getDefinition('notifier.failed_message_listener')->addTag('kernel.event_subscriber');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2193,12 +2193,6 @@ public function testNotifierWithSpecificMessageBus()
$this->assertEquals(new Reference('app.another_bus'), $container->getDefinition('notifier.channel.chat')->getArgument(1));
$this->assertEquals(new Reference('app.another_bus'), $container->getDefinition('notifier.channel.email')->getArgument(1));
$this->assertEquals(new Reference('app.another_bus'), $container->getDefinition('notifier.channel.sms')->getArgument(1));

$this->assertNull($container->getDefinition('chatter')->getArgument(0));
$this->assertNull($container->getDefinition('texter')->getArgument(0));
$this->assertNull($container->getDefinition('notifier.channel.chat')->getArgument(0));
$this->assertNull($container->getDefinition('notifier.channel.email')->getArgument(0));
$this->assertNull($container->getDefinition('notifier.channel.sms')->getArgument(0));
}

protected function createContainer(array $data = [])
Expand Down
0