Skip to content

Commit

Permalink
Merge pull request #81 from chives/2.1
Browse files Browse the repository at this point in the history
Fixed compatibility with symfony/dependency-injection ^5.0
  • Loading branch information
rn0 authored Feb 15, 2021
2 parents 8b46861 + 42a3b04 commit 2be6a7d
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions DependencyInjection/Compiler/DataSourcePass.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand Down

0 comments on commit 2be6a7d

Please sign in to comment.