瀏覽代碼

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

Fabien Potencier 13 年之前
父節點
當前提交
906f6f662c

+ 3 - 0
src/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php

@@ -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()));
+                }
             }
         }
 

+ 8 - 1
tests/Symfony/Tests/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPassTest.php

@@ -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()