Skip to content

Commit 124ede8

Browse files
committed
Merge branch '6.1' into 6.2
* 6.1: execute tests with the full range of supported Messenger component releases
2 parents 4e0f52c + ac06ad1 commit 124ede8

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

DependencyInjection/FrameworkExtension.php

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
use Symfony\Component\Messenger\MessageBus;
117117
use Symfony\Component\Messenger\MessageBusInterface;
118118
use Symfony\Component\Messenger\Middleware\RouterContextMiddleware;
119+
use Symfony\Component\Messenger\Stamp\SerializedMessageStamp;
119120
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
120121
use Symfony\Component\Messenger\Transport\TransportFactoryInterface;
121122
use Symfony\Component\Messenger\Transport\TransportInterface;
@@ -664,18 +665,30 @@ public function load(array $configs, ContainerBuilder $container)
664665
$container->registerAttributeForAutoconfiguration(AsController::class, static function (ChildDefinition $definition, AsController $attribute): void {
665666
$definition->addTag('controller.service_arguments');
666667
});
667-
$container->registerAttributeForAutoconfiguration(AsMessageHandler::class, static function (ChildDefinition $definition, AsMessageHandler $attribute, \ReflectionClass|\ReflectionMethod $reflector): void {
668-
$tagAttributes = get_object_vars($attribute);
669-
$tagAttributes['from_transport'] = $tagAttributes['fromTransport'];
670-
unset($tagAttributes['fromTransport']);
671-
if ($reflector instanceof \ReflectionMethod) {
672-
if (isset($tagAttributes['method'])) {
673-
throw new LogicException(sprintf('AsMessageHandler attribute cannot declare a method on "%s::%s()".', $reflector->class, $reflector->name));
668+
669+
if (class_exists(SerializedMessageStamp::class)) {
670+
// symfony/messenger >= 6.1
671+
$container->registerAttributeForAutoconfiguration(AsMessageHandler::class, static function (ChildDefinition $definition, AsMessageHandler $attribute, \ReflectionClass|\ReflectionMethod $reflector): void {
672+
$tagAttributes = get_object_vars($attribute);
673+
$tagAttributes['from_transport'] = $tagAttributes['fromTransport'];
674+
unset($tagAttributes['fromTransport']);
675+
if ($reflector instanceof \ReflectionMethod) {
676+
if (isset($tagAttributes['method'])) {
677+
throw new LogicException(sprintf('AsMessageHandler attribute cannot declare a method on "%s::%s()".', $reflector->class, $reflector->name));
678+
}
679+
$tagAttributes['method'] = $reflector->getName();
674680
}
675-
$tagAttributes['method'] = $reflector->getName();
676-
}
677-
$definition->addTag('messenger.message_handler', $tagAttributes);
678-
});
681+
$definition->addTag('messenger.message_handler', $tagAttributes);
682+
});
683+
} else {
684+
// symfony/messenger < 6.1
685+
$container->registerAttributeForAutoconfiguration(AsMessageHandler::class, static function (ChildDefinition $definition, AsMessageHandler $attribute): void {
686+
$tagAttributes = get_object_vars($attribute);
687+
$tagAttributes['from_transport'] = $tagAttributes['fromTransport'];
688+
unset($tagAttributes['fromTransport']);
689+
$definition->addTag('messenger.message_handler', $tagAttributes);
690+
});
691+
}
679692

680693
if (!$container->getParameter('kernel.debug')) {
681694
// remove tagged iterator argument for resource checkers

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"symfony/http-client": "^5.4|^6.0",
4949
"symfony/lock": "^5.4|^6.0",
5050
"symfony/mailer": "^5.4|^6.0",
51-
"symfony/messenger": "^6.1",
51+
"symfony/messenger": "^5.4|^6.0",
5252
"symfony/mime": "^5.4|^6.0",
5353
"symfony/notifier": "^5.4|^6.0",
5454
"symfony/process": "^5.4|^6.0",

0 commit comments

Comments
 (0)