From 42a3b04b703497ec856773c60d69f35fe82d6c9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Cybula?= Date: Sat, 13 Feb 2021 00:44:15 +0100 Subject: [PATCH] Fixed compatibility with symfony/dependency-injection ^5.0 --- .../Compiler/DataSourcePass.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/DependencyInjection/Compiler/DataSourcePass.php b/DependencyInjection/Compiler/DataSourcePass.php index a7ade7f..b12aedc 100644 --- a/DependencyInjection/Compiler/DataSourcePass.php +++ b/DependencyInjection/Compiler/DataSourcePass.php @@ -15,6 +15,8 @@ use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Reference; +use function array_map; + final class DataSourcePass implements CompilerPassInterface { public function process(ContainerBuilder $container) @@ -32,16 +34,19 @@ public function process(ContainerBuilder $container) $extensions = []; foreach ($container->findTaggedServiceIds('datasource.driver.extension') as $serviceId => $tag) { - $alias = isset($tag[0]['alias']) ? $tag[0]['alias'] : $serviceId; + $alias = $tag[0]['alias'] ?? $serviceId; - $extensions[$alias] = new Reference($serviceId); + $extensions[$alias] = $serviceId; } - $container->getDefinition('datasource.extension')->replaceArgument(0, $extensions); + $extensionsReferences = array_map(static function (string $extensionId): Reference { + return new Reference($extensionId); + }, $extensions); + $container->getDefinition('datasource.extension')->replaceArgument(0, $extensionsReferences); $subscribers = []; foreach ($container->findTaggedServiceIds('datasource.subscriber') as $serviceId => $tag) { - $alias = isset($tag[0]['alias']) ? $tag[0]['alias'] : $serviceId; + $alias = $tag[0]['alias'] ?? $serviceId; $subscribers[$alias] = new Reference($serviceId); } @@ -54,7 +59,7 @@ public function process(ContainerBuilder $container) $fields = []; $fieldTag = 'datasource.driver.' . $driverType . '.field'; foreach ($container->findTaggedServiceIds($fieldTag) as $serviceId => $tag) { - $alias = isset($tag[0]['alias']) ? $tag[0]['alias'] : $serviceId; + $alias = $tag[0]['alias'] ?? $serviceId; $fields[$alias] = new Reference($serviceId); } @@ -64,7 +69,7 @@ public function process(ContainerBuilder $container) $fieldSubscribers = []; $fieldSubscriberTag = 'datasource.driver.' . $driverType . '.field.subscriber'; foreach ($container->findTaggedServiceIds($fieldSubscriberTag) as $serviceId => $tag) { - $alias = isset($tag[0]['alias']) ? $tag[0]['alias'] : $serviceId; + $alias = $tag[0]['alias'] ?? $serviceId; $fieldSubscribers[$alias] = new Reference($serviceId); } @@ -74,7 +79,7 @@ public function process(ContainerBuilder $container) $subscribers = []; $driverSubscriberTag = 'datasource.driver.' . $driverType . '.subscriber'; foreach ($container->findTaggedServiceIds($driverSubscriberTag) as $serviceId => $tag) { - $alias = isset($tag[0]['alias']) ? $tag[0]['alias'] : $serviceId; + $alias = $tag[0]['alias'] ?? $serviceId; $subscribers[$alias] = new Reference($serviceId); }