Skip to content

Commit

Permalink
[DependencyInjection] fixed un-detected circular references involving…
Browse files Browse the repository at this point in the history
… aliases
  • Loading branch information
fabpot committed Jul 11, 2011
1 parent be31bc0 commit e718a51
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Expand Up @@ -95,7 +95,7 @@ private function processArguments(array $arguments)
$this->graph->connect(
$this->currentId,
$this->currentDefinition,
(string) $argument,
$this->getDefinitionId((string) $argument),
$this->getDefinition((string) $argument),
$argument
);
Expand All @@ -114,6 +114,13 @@ private function processArguments(array $arguments)
* @return Definition The definition related to the supplied id
*/
private function getDefinition($id)
{
$id = $this->getDefinitionId($id);

return null === $id ? null : $this->container->getDefinition($id);
}

private function getDefinitionId($id)
{
while ($this->container->hasAlias($id)) {
$id = (string) $this->container->getAlias($id);
Expand All @@ -123,6 +130,6 @@ private function getDefinition($id)
return null;
}

return $this->container->getDefinition($id);
return $id;
}
}
Expand Up @@ -35,6 +35,19 @@ public function testProcess()
$this->process($container);
}

/**
* @expectedException \RuntimeException
*/
public function testProcessWithAliases()
{
$container = new ContainerBuilder();
$container->register('a')->addArgument(new Reference('b'));
$container->setAlias('b', 'c');
$container->setAlias('c', 'a');

$this->process($container);
}

/**
* @expectedException \RuntimeException
*/
Expand Down

0 comments on commit e718a51

Please sign in to comment.