10000 Forces the `default_bus` to match with a bus only when multiple of them · symfony/symfony@d39604e · GitHub
[go: up one dir, main page]

Skip to content

Commit d39604e

Browse files
committed
Forces the default_bus to match with a bus only when multiple of them
1 parent 0d78a0e commit d39604e

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ function ($a) {
10531053
->end()
10541054
->end()
10551055
->end()
1056-
->scalarNode('default_bus')->defaultValue('default')->end()
1056+
->scalarNode('default_bus')->defaultValue(null)->end()
10571057
->arrayNode('buses')
10581058
->defaultValue(array('default' => array('middlewares' => $defaultMiddlewares = array('logging', 'route_messages', 'call_message_handler'))))
10591059
->useAttributeAsKey('name')

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,6 +1463,14 @@ private function registerMessengerConfiguration(array $config, ContainerBuilder
14631463
$container->setAlias('messenger.transport.encoder', $config['encoder']);
14641464
$container->setAlias('messenger.transport.decoder', $config['decoder']);
14651465

1466+
if (null === $config['default_bus']) {
1467+
if (count($config['buses']) > 1) {
1468+
throw new LogicException(sprintf('You need to define a default bus with the "default_bus" configuration. Possible values: %s', implode(', ', array_keys($config['buses']))));
1469+
}
1470+
1471+
$config['default_bus'] = array_keys($config['buses'])[0];
1472+
}
1473+
14661474
foreach ($config['buses'] as $name => $bus) {
14671475
$busId = 'messenger.bus.'.$name;
14681476

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphor
267267
),
268268
'encoder' => 'messenger.transport.serializer',
269269
'decoder' => 'messenger.transport.serializer',
270-
'default_bus' => 'default',
270+
'default_bus' => null,
271271
'buses' => array('default' => array('middlewares' => array('logging', 'route_messages', 'call_message_handler'))),
272272
),
273273
);

0 commit comments

Comments
 (0)
0