From 906f6f662c3825801a976d990e02142e0867a5f7 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 7 May 2012 12:47:50 +0200 Subject: [PATCH] [DependencyInjection] fixed private services removal when used as configurators (closes #3758) --- .../Compiler/AnalyzeServiceReferencesPass.php | 3 +++ .../Compiler/AnalyzeServiceReferencesPassTest.php | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php b/src/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php index b565f3f83e34..19079b4038da 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php @@ -74,6 +74,9 @@ public function process(ContainerBuilder $container) if (!$this->onlyConstructorArguments) { $this->processArguments($definition->getMethodCalls()); $this->processArguments($definition->getProperties()); + if ($definition->getConfigurator()) { + $this->processArguments(array($definition->getConfigurator())); + } } } diff --git a/tests/Symfony/Tests/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPassTest.php b/tests/Symfony/Tests/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPassTest.php index 40ed58f38d8b..50419a84900a 100644 --- a/tests/Symfony/Tests/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPassTest.php +++ b/tests/Symfony/Tests/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPassTest.php @@ -45,12 +45,19 @@ public function testProcess() ->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()