Skip to content

Commit

Permalink
TASK: Subsitute MessageSubscriberInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
sabbelasichon committed Jan 16, 2024
1 parent 5638e2c commit 3cdc5c5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
42 changes: 33 additions & 9 deletions Configuration/Services.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 3cdc5c5

Please sign in to comment.