diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 2b4ddb9ba5..4263acc5dd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -1193,6 +1193,10 @@ class Configuration implements ConfigurationInterface if (!\is_array($config)) { return []; } + // If XML config with only one routing attribute + if (2 === \count($config) && isset($config['message-class']) && isset($config['sender'])) { + $config = [0 => $config]; + } $newConfig = []; foreach ($config as $k => $v) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_routing_single.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_routing_single.php new file mode 100644 index 0000000000..e58814589b --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_routing_single.php @@ -0,0 +1,12 @@ +loadFromExtension('framework', [ + 'messenger' => [ + 'routing' => [ + 'Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummyMessage' => ['amqp'], + ], + 'transports' => [ + 'amqp' => 'amqp://localhost/%2f/messages', + ], + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_routing_single.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_routing_single.xml new file mode 100644 index 0000000000..349a3728d3 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_routing_single.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_routing_single.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_routing_single.yml new file mode 100644 index 0000000000..caa8864188 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_routing_single.yml @@ -0,0 +1,7 @@ +framework: + messenger: + routing: + 'Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummyMessage': [amqp] + + transports: + amqp: 'amqp://localhost/%2f/messages' diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index e80b52a0c2..2d494932df 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -740,6 +740,15 @@ abstract class FrameworkExtensionTest extends TestCase $this->assertEquals(new Reference('messenger.transport.audit'), $sendersLocator->getArgument(0)['messenger.transport.audit']->getValues()[0]); } + public function testMessengerRoutingSingle() + { + $container = $this->createContainerFromFile('messenger_routing_single'); + $senderLocatorDefinition = $container->getDefinition('messenger.senders_locator'); + + $sendersMapping = $senderLocatorDefinition->getArgument(0); + $this->assertEquals(['amqp'], $sendersMapping[DummyMessage::class]); + } + public function testMessengerTransportConfiguration() { $container = $this->createContainerFromFile('messenger_transport');