Skip to content

[Messenger] Deprecate passing a bus locator to ConsumeMessagesCommand's constructor #31785

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 1 commit into from
Jun 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 9 additions & 3 deletions UPGRADE-4.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ UPGRADE FROM 4.3 to 4.4
HttpKernel
----------

* The `DebugHandlersListener` class has been marked as `final`
* The `DebugHandlersListener` class has been marked as `final`

DependencyInjection
-------------------
Expand All @@ -25,13 +25,19 @@ DependencyInjection
factory: ['@factory_service', method]
```

Messenger
---------

* Deprecated passing a `ContainerInterface` instance as first argument of the `ConsumeMessagesCommand` constructor,
pass a `RoutableMessageBus` instance instead.

MonologBridge
--------------

* The `RouteProcessor` has been marked final.
* The `RouteProcessor` has been marked final.

TwigBridge
----------

* Deprecated to pass `$rootDir` and `$fileLinkFormatter` as 5th and 6th argument respectively to the
`DebugCommand::__construct()` method, swap the variables position.
`DebugCommand::__construct()` method, swap the variables position.
2 changes: 2 additions & 0 deletions UPGRADE-5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ Messenger
---------

* The `LoggingMiddleware` class has been removed, pass a logger to `SendMessageMiddleware` instead.
* Passing a `ContainerInterface` instance as first argument of the `ConsumeMessagesCommand` constructor now
throws as `\TypeError`, pass a `RoutableMessageBus` instance instead.

Monolog
-------
Expand Down
6 changes: 6 additions & 0 deletions src/Symfony/Component/Messenger/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
CHANGELOG
=========

4.4.0
-----

* Deprecated passing a `ContainerInterface` instance as first argument of the `ConsumeMessagesCommand` constructor,
pass a `RoutableMessageBus` instance instead.

4.3.0
-----

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class ConsumeMessagesCommand extends Command
*/
public function __construct($routableBus, ContainerInterface $receiverLocator, LoggerInterface $logger = null, array $receiverNames = [], /* ContainerInterface */ $retryStrategyLocator = null, EventDispatcherInterface $eventDispatcher = null)
{
// to be deprecated in 4.4
if ($routableBus instanceof ContainerInterface) {
@trigger_error(sprintf('Passing a "%s" instance as first argument to "%s()" is deprecated since Symfony 4.4, pass a "%s" instance instead.', ContainerInterface::class, __METHOD__, RoutableMessageBus::class), E_USER_DEPRECATED);
$routableBus = new RoutableMessageBus($routableBus);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ConsumeMessagesCommandTest extends TestCase
{
public function testConfigurationWithDefaultReceiver()
{
$command = new ConsumeMessagesCommand($this->createMock(ServiceLocator::class), $this->createMock(ServiceLocator::class), null, ['amqp']);
$command = new ConsumeMessagesCommand($this->createMock(RoutableMessageBus::class), $this->createMock(ServiceLocator::class), null, ['amqp']);
$inputArgument = $command->getDefinition()->getArgument('receivers');
$this->assertFalse($inputArgument->isRequired());
$this->assertSame(['amqp'], $inputArgument->getDefault());
Expand Down Expand Up @@ -98,6 +98,10 @@ public function testRunWithBusOption()
$this->assertContains('[OK] Consuming messages from transports "dummy-receiver"', $tester->getDisplay());
}

/**
* @group legacy
* @expectedDeprecation Passing a "Psr\Container\ContainerInterface" instance as first argument to "Symfony\Component\Messenger\Command\ConsumeMessagesCommand::__construct()" is deprecated since Symfony 4.4, pass a "Symfony\Component\Messenger\RoutableMessageBus" instance instead.
*/
public function testBasicRunWithBusLocator()
{
$envelope = new Envelope(new \stdClass(), [new BusNameStamp('dummy-bus')]);
Expand Down Expand Up @@ -130,6 +134,10 @@ public function testBasicRunWithBusLocator()
$this->assertContains('[OK] Consuming messages from transports "dummy-receiver"', $tester->getDisplay());
}

/**
* @group legacy
* @expectedDeprecation Passing a "Psr\Container\ContainerInterface" instance as first argument to "Symfony\Component\Messenger\Command\ConsumeMessagesCommand::__construct()" is deprecated since Symfony 4.4, pass a "Symfony\Component\Messenger\RoutableMessageBus" instance instead.
*/
public function testRunWithBusOptionAndBusLocator()
{
$envelope = new Envelope(new \stdClass());
Expand Down