diff --git a/Civi/RemoteTools/DependencyInjection/Compiler/ActionHandlerPass.php b/Civi/RemoteTools/DependencyInjection/Compiler/ActionHandlerPass.php index 107214b..0b983f2 100644 --- a/Civi/RemoteTools/DependencyInjection/Compiler/ActionHandlerPass.php +++ b/Civi/RemoteTools/DependencyInjection/Compiler/ActionHandlerPass.php @@ -23,6 +23,7 @@ use Civi\RemoteTools\ActionHandler\ActionHandlerInterface; use Civi\RemoteTools\ActionHandler\ActionHandlerProvider; use Civi\RemoteTools\ActionHandler\RemoteActionsHandlerTransactionDecorator; +use Civi\RemoteTools\ActionHandler\RemoteEntityActionsHandlerInterface; use Civi\RemoteTools\DependencyInjection\Compiler\Traits\DecorateServiceTrait; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass; @@ -84,12 +85,7 @@ public function process(ContainerBuilder $container): void { } foreach ($handlerServices as $handlerKey => $handlerService) { - $this->decorateService( - $container, - $handlerService->__toString(), - RemoteActionsHandlerTransactionDecorator::class, - $handlerKey - ); + $this->decorateWithTransactionDecorator($container, $handlerService->__toString(), $handlerKey); } $container->getDefinition(ActionHandlerProvider::class) @@ -200,4 +196,16 @@ private function isClassAllowedByType(string $class, \ReflectionType $reflType): return NULL; } + private function decorateWithTransactionDecorator(ContainerBuilder $container, string $id, string $handlerKey): void { + $handlerClass = $this->getServiceClass($container, $id); + if (is_a($handlerClass, RemoteEntityActionsHandlerInterface::class, TRUE)) { + $this->decorateService( + $container, + $id, + RemoteActionsHandlerTransactionDecorator::class, + $handlerKey + ); + } + } + }