diff --git a/Configuration/Services.php b/Configuration/Services.php index 336a6f3..d7e15c2 100644 --- a/Configuration/Services.php +++ b/Configuration/Services.php @@ -32,6 +32,7 @@ use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\Compiler\PassConfig; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Exception\LogicException; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use Symfony\Component\DependencyInjection\ServiceLocator; use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass; @@ -381,15 +382,38 @@ class_alias( // Register autoconfiguration for message handlers via interface or attributes $containerBuilder->registerForAutoconfiguration(MessageHandlerInterface::class) ->addTag('messenger.message_handler'); - $containerBuilder->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 (PHP_VERSION_ID < 80000) { + $containerBuilder->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); + } + ); + } else { + $containerBuilder->registerAttributeForAutoconfiguration( + AsMessageHandler::class, + static function (ChildDefinition $definition, AsMessageHandler $attribute, $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(); + } + $definition->addTag('messenger.message_handler', $tagAttributes); + } + ); + } // Register autoconfiguration for transports $containerBuilder->registerForAutoconfiguration(TransportFactoryInterface::class) diff --git a/ext_emconf.php b/ext_emconf.php index 10270d9..3e9568b 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -11,7 +11,7 @@ 'uploadfolder' => '0', 'createDirs' => '', 'clearCacheOnLoad' => 0, - 'version' => '2.0.0', + 'version' => '2.0.1', 'constraints' => [ 'depends' => [ 'typo3' => '10.4.0-12.9.99',