[Messenger] Deprecate passing a bus locator to ConsumeMessagesCommand constructor
This commit is contained in:
parent
d7753035f8
commit
14093386e6
@ -4,7 +4,7 @@ UPGRADE FROM 4.3 to 4.4
|
|||||||
HttpKernel
|
HttpKernel
|
||||||
----------
|
----------
|
||||||
|
|
||||||
* The `DebugHandlersListener` class has been marked as `final`
|
* The `DebugHandlersListener` class has been marked as `final`
|
||||||
|
|
||||||
DependencyInjection
|
DependencyInjection
|
||||||
-------------------
|
-------------------
|
||||||
@ -25,13 +25,19 @@ DependencyInjection
|
|||||||
factory: ['@factory_service', method]
|
factory: ['@factory_service', method]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Messenger
|
||||||
|
---------
|
||||||
|
|
||||||
|
* Deprecated passing a `ContainerInterface` instance as first argument of the `ConsumeMessagesCommand` constructor,
|
||||||
|
pass a `RoutableMessageBus` instance instead.
|
||||||
|
|
||||||
MonologBridge
|
MonologBridge
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
* The `RouteProcessor` has been marked final.
|
* The `RouteProcessor` has been marked final.
|
||||||
|
|
||||||
TwigBridge
|
TwigBridge
|
||||||
----------
|
----------
|
||||||
|
|
||||||
* Deprecated to pass `$rootDir` and `$fileLinkFormatter` as 5th and 6th argument respectively to the
|
* 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.
|
||||||
|
@ -269,6 +269,8 @@ Messenger
|
|||||||
---------
|
---------
|
||||||
|
|
||||||
* The `LoggingMiddleware` class has been removed, pass a logger to `SendMessageMiddleware` instead.
|
* 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
|
Monolog
|
||||||
-------
|
-------
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
CHANGELOG
|
CHANGELOG
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
4.4.0
|
||||||
|
-----
|
||||||
|
|
||||||
|
* Deprecated passing a `ContainerInterface` instance as first argument of the `ConsumeMessagesCommand` constructor,
|
||||||
|
pass a `RoutableMessageBus` instance instead.
|
||||||
|
|
||||||
4.3.0
|
4.3.0
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
@ -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)
|
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) {
|
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);
|
$routableBus = new RoutableMessageBus($routableBus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ class ConsumeMessagesCommandTest extends TestCase
|
|||||||
{
|
{
|
||||||
public function testConfigurationWithDefaultReceiver()
|
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');
|
$inputArgument = $command->getDefinition()->getArgument('receivers');
|
||||||
$this->assertFalse($inputArgument->isRequired());
|
$this->assertFalse($inputArgument->isRequired());
|
||||||
$this->assertSame(['amqp'], $inputArgument->getDefault());
|
$this->assertSame(['amqp'], $inputArgument->getDefault());
|
||||||
@ -98,6 +98,10 @@ class ConsumeMessagesCommandTest extends TestCase
|
|||||||
$this->assertContains('[OK] Consuming messages from transports "dummy-receiver"', $tester->getDisplay());
|
$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()
|
public function testBasicRunWithBusLocator()
|
||||||
{
|
{
|
||||||
$envelope = new Envelope(new \stdClass(), [new BusNameStamp('dummy-bus')]);
|
$envelope = new Envelope(new \stdClass(), [new BusNameStamp('dummy-bus')]);
|
||||||
@ -130,6 +134,10 @@ class ConsumeMessagesCommandTest extends TestCase
|
|||||||
$this->assertContains('[OK] Consuming messages from transports "dummy-receiver"', $tester->getDisplay());
|
$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()
|
public function testRunWithBusOptionAndBusLocator()
|
||||||
{
|
{
|
||||||
$envelope = new Envelope(new \stdClass());
|
$envelope = new Envelope(new \stdClass());
|
||||||
|
Reference in New Issue
Block a user