bug #26804 [Messenger] Fix handles tag attribute (ro0NL)
This PR was squashed before being merged into the 4.1-dev branch (closes #26804).
Discussion
----------
[Messenger] Fix handles tag attribute
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | yes
| New feature? | no
| BC breaks? | no <!-- see https://symfony.com/bc -->
| Deprecations? | no
| Tests pass? | yes <!-- please add some, will be required by reviewers -->
| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->
| License | MIT
| Doc PR | symfony/symfony-docs#... <!-- required for new features -->
<!--
Write a short README entry for your feature/bugfix here (replace this comment block.)
This will help people understand your PR and can be used as a start of the Doc PR.
Additionally:
- Bug fixes must be submitted against the lowest branch where they apply
(lowest branches are regularly merged to upper ones so they get the fixes too).
- Features and deprecations must be submitted against the master branch.
-->
Commits
-------
92f7e37a27
[Messenger] Fix handles tag attribute
This commit is contained in:
commit
08ca9f5a56
@ -69,7 +69,7 @@ class MessengerPass implements CompilerPassInterface
|
|||||||
|
|
||||||
foreach ($container->findTaggedServiceIds($this->handlerTag, true) as $serviceId => $tags) {
|
foreach ($container->findTaggedServiceIds($this->handlerTag, true) as $serviceId => $tags) {
|
||||||
foreach ($tags as $tag) {
|
foreach ($tags as $tag) {
|
||||||
$handles = $tag['handles'] ?? $this->guessHandledClasses($r = $container->getReflectionClass($container->getDefinition($serviceId)->getClass()), $serviceId);
|
$handles = isset($tag['handles']) ? array($tag['handles']) : $this->guessHandledClasses($r = $container->getReflectionClass($container->getDefinition($serviceId)->getClass()), $serviceId);
|
||||||
$priority = $tag['priority'] ?? 0;
|
$priority = $tag['priority'] ?? 0;
|
||||||
|
|
||||||
foreach ($handles as $messageClass) {
|
foreach ($handles as $messageClass) {
|
||||||
|
@ -33,6 +33,10 @@ class MessengerPassTest extends TestCase
|
|||||||
->register(DummyHandler::class, DummyHandler::class)
|
->register(DummyHandler::class, DummyHandler::class)
|
||||||
->addTag('messenger.message_handler')
|
->addTag('messenger.message_handler')
|
||||||
;
|
;
|
||||||
|
$container
|
||||||
|
->register(MissingArgumentTypeHandler::class, MissingArgumentTypeHandler::class)
|
||||||
|
->addTag('messenger.message_handler', array('handles' => SecondMessage::class))
|
||||||
|
;
|
||||||
$container
|
$container
|
||||||
->register(DummyReceiver::class, DummyReceiver::class)
|
->register(DummyReceiver::class, DummyReceiver::class)
|
||||||
->addTag('messenger.receiver')
|
->addTag('messenger.receiver')
|
||||||
@ -43,7 +47,10 @@ class MessengerPassTest extends TestCase
|
|||||||
$handlerLocatorDefinition = $container->getDefinition($container->getDefinition('messenger.handler_resolver')->getArgument(0));
|
$handlerLocatorDefinition = $container->getDefinition($container->getDefinition('messenger.handler_resolver')->getArgument(0));
|
||||||
$this->assertSame(ServiceLocator::class, $handlerLocatorDefinition->getClass());
|
$this->assertSame(ServiceLocator::class, $handlerLocatorDefinition->getClass());
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
array('handler.'.DummyMessage::class => new ServiceClosureArgument(new Reference(DummyHandler::class))),
|
array(
|
||||||
|
'handler.'.DummyMessage::class => new ServiceClosureArgument(new Reference(DummyHandler::class)),
|
||||||
|
'handler.'.SecondMessage::class => new ServiceClosureArgument(new Reference(MissingArgumentTypeHandler::class)),
|
||||||
|
),
|
||||||
$handlerLocatorDefinition->getArgument(0)
|
$handlerLocatorDefinition->getArgument(0)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user