Skip to content

Commit 9e177f7

Browse files
committed
execute tests with the full range of supported Messenger component releases
The conflict rule does not exclude the 5.4 and 6.0 releases of the Messenger component. So we should make sure that we also run tests against these versions.
1 parent 971f006 commit 9e177f7

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
@@ -113,6 +113,7 @@
113113
use Symfony\Component\Messenger\MessageBus;
114114
use Symfony\Component\Messenger\MessageBusInterface;
115115
use Symfony\Component\Messenger\Middleware\RouterContextMiddleware;
116+
use Symfony\Component\Messenger\Stamp\SerializedMessageStamp;
116117
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
117118
use Symfony\Component\Messenger\Transport\TransportFactoryInterface;
118119
use Symfony\Component\Messenger\Transport\TransportInterface;
@@ -651,18 +652,30 @@ public function load(array $configs, ContainerBuilder $container)
651652
$container->registerAttributeForAutoconfiguration(AsController::class, static function (ChildDefinition $definition, AsController $attribute): void {
652653
$definition->addTag('controller.service_arguments');
653654
});
654-
$container->registerAttributeForAutoconfiguration(AsMessageHandler::class, static function (ChildDefinition $definition, AsMessageHandler $attribute, \ReflectionClass|\ReflectionMethod $reflector): void {
655-
$tagAttributes = get_object_vars($attribute);
656-
$tagAttributes['from_transport'] = $tagAttributes['fromTransport'];
657-
unset($tagAttributes['fromTransport']);
658-
if ($reflector instanceof \ReflectionMethod) {
659-
if (isset($tagAttributes['method'])) {
660-
throw new LogicException(sprintf('AsMessageHandler attribute cannot declare a method on "%s::%s()".', $reflector->class, $reflector->name));
655+
656+
if (class_exists(SerializedMessageStamp::class)) {
657+
// symfony/messenger >= 6.1
658+
$container->registerAttributeForAutoconfiguration(AsMessageHandler::class, static function (ChildDefinition $definition, AsMessageHandler $attribute, \ReflectionClass|\ReflectionMethod $reflector): void {
659+
$tagAttributes = get_object_vars($attribute);
660+
$tagAttributes['from_transport'] = $tagAttributes['fromTransport'];
661+
unset($tagAttributes['fromTransport']);
662+
if ($reflector instanceof \ReflectionMethod) {
663+
if (isset($tagAttributes['method'])) {
664+
throw new LogicException(sprintf('AsMessageHandler attribute cannot declare a method on "%s::%s()".', $reflector->class, $reflector->name));
665+
}
666+
$tagAttributes['method'] = $reflector->getName();
661667
}
662-
$tagAttributes['method'] = $reflector->getName();
663-
}
664-
$definition->addTag('messenger.message_handler', $tagAttributes);
665-
});
668+
$definition->addTag('messenger.message_handler', $tagAttributes);
669+
});
670+
} else {
671+
// symfony/messenger < 6.1
672+
$container->registerAttributeForAutoconfiguration(AsMessageHandler::class, static function (ChildDefinition $definition, AsMessageHandler $attribute): void {
673+
$tagAttributes = get_object_vars($attribute);
674+
$tagAttributes['from_transport'] = $tagAttributes['fromTransport'];
675+
unset($tagAttributes['fromTransport']);
676+
$definition->addTag('messenger.message_handler', $tagAttributes);
677+
});
678+
}
666679

667680
if (!$container->getParameter('kernel.debug')) {
668681
// 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)