Skip to content

Commit

Permalink
ActionHandlerPass: Only decorate handlers that implement `RemoteEntit…
Browse files Browse the repository at this point in the history
…yActionsHandlerInterface` with `RemoteActionsHandlerTransactionDecorator`
  • Loading branch information
Dominic Tubach committed Sep 6, 2024
1 parent 5f8b514 commit 5d06e97
Showing 1 changed file with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
);
}
}

}

0 comments on commit 5d06e97

Please sign in to comment.