Skip to content
Permalink
Browse files

feature #30690 Changing messenger bus id from 'message_bus' to 'messe…

…nger.default_bus' (THERAGE Kévin)

This PR was merged into the 4.3-dev branch.

Discussion
----------

Changing messenger bus id from 'message_bus' to 'messenger.default_bus'

Changing messenger bus tag from 'message_bus' to 'messenger.message_bus'

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | Maybe
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #30670
| License       | MIT
| Doc PR |

All is in the title.
This PR change the tag of the default bus from 'message_bus' to 'messenger.message_bus'.

Commits
-------

3cee1ca #30690 - Changing messenger bus id from 'message_bus' to 'messenger.default_bus'
  • Loading branch information...
fabpot committed Apr 1, 2019
2 parents b921076 + 3cee1ca commit 1fcc99402137471d68996ffb4b466e3aaee19447
@@ -88,6 +88,7 @@ public static function getSubscribedServices()
'security.csrf.token_manager' => '?'.CsrfTokenManagerInterface::class,
'parameter_bag' => '?'.ContainerBagInterface::class,
'message_bus' => '?'.MessageBusInterface::class,
'messenger.default_bus' => '?'.MessageBusInterface::class,
];
}
}
@@ -403,12 +403,12 @@ protected function isCsrfTokenValid(string $id, ?string $token): bool
*/
protected function dispatchMessage($message): Envelope
{
if (!$this->container->has('message_bus')) {
if (!$this->container->has('messenger.default_bus')) {
$message = class_exists(Envelope::class) ? 'You need to define the "messenger.default_bus" configuration option.' : 'Try running "composer require symfony/messenger".';
throw new \LogicException('The message bus is not enabled in your application. '.$message);
}
return $this->container->get('message_bus')->dispatch($message);
return $this->container->get('messenger.default_bus')->dispatch($message);
}
/**
@@ -1647,7 +1647,8 @@ private function registerMessengerConfiguration(array $config, ContainerBuilder
$container->register($busId, MessageBus::class)->addArgument([])->addTag('messenger.bus');
if ($busId === $config['default_bus']) {
$container->setAlias('message_bus', $busId)->setPublic(true);
$container->setAlias('message_bus', $busId)->setPublic(true)->setDeprecated(true, 'The "%alias_id%" service is deprecated, use the "messenger.default_bus" service instead.');
$container->setAlias('messenger.default_bus', $busId)->setPublic(true);
$container->setAlias(MessageBusInterface::class, $busId);
} else {
$container->registerAliasForArgument($busId, MessageBusInterface::class);
@@ -43,6 +43,7 @@ public function testSubscribedServices()
'form.factory' => '?Symfony\\Component\\Form\\FormFactoryInterface',
'parameter_bag' => '?Symfony\\Component\\DependencyInjection\\ParameterBag\\ContainerBagInterface',
'message_bus' => '?Symfony\\Component\\Messenger\\MessageBusInterface',
'messenger.default_bus' => '?Symfony\\Component\\Messenger\\MessageBusInterface',
'security.token_storage' => '?Symfony\\Component\\Security\\Core\\Authentication\\Token\\Storage\\TokenStorageInterface',
'security.csrf.token_manager' => '?Symfony\\Component\\Security\\Csrf\\CsrfTokenManagerInterface',
];
@@ -650,6 +650,8 @@ public function testMessenger()
$container = $this->createContainerFromFile('messenger');
$this->assertTrue($container->hasAlias('message_bus'));
$this->assertTrue($container->getAlias('message_bus')->isPublic());
$this->assertTrue($container->hasAlias('messenger.default_bus'));
$this->assertTrue($container->getAlias('messenger.default_bus')->isPublic());
$this->assertFalse($container->hasDefinition('messenger.transport.amqp.factory'));
$this->assertTrue($container->hasDefinition('messenger.transport_factory'));
$this->assertSame(TransportFactory::class, $container->getDefinition('messenger.transport_factory')->getClass());
@@ -737,6 +739,8 @@ public function testMessengerWithMultipleBuses()
$this->assertTrue($container->hasAlias('message_bus'));
$this->assertSame('messenger.bus.commands', (string) $container->getAlias('message_bus'));
$this->assertTrue($container->hasAlias('messenger.default_bus'));
$this->assertSame('messenger.bus.commands', (string) $container->getAlias('messenger.default_bus'));
}
/**

0 comments on commit 1fcc994

Please sign in to comment.
You can’t perform that action at this time.