Skip to content

Commit

Permalink
Use definition if it's already been added to the container, so we can…
Browse files Browse the repository at this point in the history
… use autowire
  • Loading branch information
davidwdan committed Nov 26, 2018
1 parent f3591c9 commit 4c100fa
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,19 @@ public function process(ContainerBuilder $container)

foreach ($files as $class) {
$class = new \ReflectionClass($class);
$serviceId = strtolower(str_replace("\\", "_", $class->getName()));
$definition = new Definition($class->getName());
$className = $class->getName();
$serviceId = strtolower(str_replace("\\", "_", $className));
$definition = $container->getDefinition($className) ? $container->getDefinition($className) : new Definition($className);

$definition->addTag('thruway.resource');

if ($class->implementsInterface('Symfony\Component\DependencyInjection\ContainerAwareInterface')) {
if (!$container->getDefinition($className)) {
if ($class->implementsInterface('Symfony\Component\DependencyInjection\ContainerAwareInterface')) {
$container->setDefinition($serviceId, $definition)
->addMethodCall('setContainer', [new Reference('thruway_container')]);
} else {
->addMethodCall('setContainer', [new Reference('thruway_container')]);
} else {
$container->setDefinition($serviceId, $definition);
}
}
}
}
Expand Down

0 comments on commit 4c100fa

Please sign in to comment.