Skip to content

Commit

Permalink
minor #47232 [FrameworkBundle] execute tests with the full range of s…
Browse files Browse the repository at this point in the history
…upported Messenger component releases (xabbuh)

This PR was merged into the 6.1 branch.

Discussion
----------

[FrameworkBundle] execute tests with the full range of supported Messenger component releases

| Q             | A
| ------------- | ---
| Branch?       | 6.1
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        |

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.

Commits
-------

e912f85 execute tests with the full range of supported Messenger component releases
  • Loading branch information
fabpot committed Aug 10, 2022
2 parents 0b8581e + e912f85 commit 1840f25
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
use Symfony\Component\Messenger\MessageBus;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Messenger\Middleware\RouterContextMiddleware;
use Symfony\Component\Messenger\Stamp\SerializedMessageStamp;
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
use Symfony\Component\Messenger\Transport\TransportFactoryInterface;
use Symfony\Component\Messenger\Transport\TransportInterface;
Expand Down Expand Up @@ -651,18 +652,30 @@ public function load(array $configs, ContainerBuilder $container)
$container->registerAttributeForAutoconfiguration(AsController::class, static function (ChildDefinition $definition, AsController $attribute): void {
$definition->addTag('controller.service_arguments');
});
$container->registerAttributeForAutoconfiguration(AsMessageHandler::class, static function (ChildDefinition $definition, AsMessageHandler $attribute, \ReflectionClass|\ReflectionMethod $reflector): void {
$tagAttributes = get_object_vars($attribute);
$tagAttributes['from_transport'] = $tagAttributes['fromTransport'];
unset($tagAttributes['fromTransport']);
if ($reflector instanceof \ReflectionMethod) {
if (isset($tagAttributes['method'])) {
throw new LogicException(sprintf('AsMessageHandler attribute cannot declare a method on "%s::%s()".', $reflector->class, $reflector->name));

if (class_exists(SerializedMessageStamp::class)) {
// symfony/messenger >= 6.1
$container->registerAttributeForAutoconfiguration(AsMessageHandler::class, static function (ChildDefinition $definition, AsMessageHandler $attribute, \ReflectionClass|\ReflectionMethod $reflector): void {
$tagAttributes = get_object_vars($attribute);
$tagAttributes['from_transport'] = $tagAttributes['fromTransport'];
unset($tagAttributes['fromTransport']);
if ($reflector instanceof \ReflectionMethod) {
if (isset($tagAttributes['method'])) {
throw new LogicException(sprintf('AsMessageHandler attribute cannot declare a method on "%s::%s()".', $reflector->class, $reflector->name));
}
$tagAttributes['method'] = $reflector->getName();
}
$tagAttributes['method'] = $reflector->getName();
}
$definition->addTag('messenger.message_handler', $tagAttributes);
});
$definition->addTag('messenger.message_handler', $tagAttributes);
});
} else {
// symfony/messenger < 6.1
$container->registerAttributeForAutoconfiguration(AsMessageHandler::class, static function (ChildDefinition $definition, AsMessageHandler $attribute): void {
$tagAttributes = get_object_vars($attribute);
$tagAttributes['from_transport'] = $tagAttributes['fromTransport'];
unset($tagAttributes['fromTransport']);
$definition->addTag('messenger.message_handler', $tagAttributes);
});
}

if (!$container->getParameter('kernel.debug')) {
// remove tagged iterator argument for resource checkers
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/FrameworkBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"symfony/http-client": "^5.4|^6.0",
"symfony/lock": "^5.4|^6.0",
"symfony/mailer": "^5.4|^6.0",
"symfony/messenger": "^6.1",
"symfony/messenger": "^5.4|^6.0",
"symfony/mime": "^5.4|^6.0",
"symfony/notifier": "^5.4|^6.0",
"symfony/process": "^5.4|^6.0",
Expand Down

0 comments on commit 1840f25

Please sign in to comment.