[DependencyInjection] fixed private services removal when used as configurators (closes #3758)

This commit is contained in:
Fabien Potencier 2012-05-07 12:47:50 +02:00
parent 6f6ee95798
commit 906f6f662c
2 changed files with 11 additions and 1 deletions

View File

@ -74,6 +74,9 @@ class AnalyzeServiceReferencesPass implements RepeatablePassInterface
if (!$this->onlyConstructorArguments) {
$this->processArguments($definition->getMethodCalls());
$this->processArguments($definition->getProperties());
if ($definition->getConfigurator()) {
$this->processArguments(array($definition->getConfigurator()));
}
}
}

View File

@ -45,12 +45,19 @@ class AnalyzeServiceReferencesPassTest extends \PHPUnit_Framework_TestCase
->setProperty('foo', $ref5 = new Reference('b'))
;
$e = $container
->register('e')
->setConfigurator(array($ref6 = new Reference('b'), 'methodName'))
;
$graph = $this->process($container);
$this->assertEquals(3, count($edges = $graph->getNode('b')->getInEdges()));
$this->assertCount(4, $edges = $graph->getNode('b')->getInEdges());
$this->assertSame($ref1, $edges[0]->getValue());
$this->assertSame($ref4, $edges[1]->getValue());
$this->assertSame($ref5, $edges[2]->getValue());
$this->assertSame($ref6, $edges[3]->getValue());
}
public function testProcessDetectsReferencesFromInlinedDefinitions()