diff --git a/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php b/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php index 77f0fe4f9432e..d9a656f78777a 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php @@ -62,9 +62,6 @@ public function process(ContainerBuilder $container) $definition->setProperties( $this->inlineArguments($container, $definition->getProperties()) ); - - $configurator = $this->inlineArguments($container, array($definition->getConfigurator())); - $definition->setConfigurator($configurator[0]); } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/InlineServiceDefinitionsPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/InlineServiceDefinitionsPassTest.php index aab7990623514..baefa1d0fff92 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/InlineServiceDefinitionsPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/InlineServiceDefinitionsPassTest.php @@ -254,6 +254,23 @@ public function testProcessDoesNotInlineFactories() $this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $factory[0]); } + public function testProcessDoesNotInlineConfigurators() + { + $container = new ContainerBuilder(); + $container + ->register('foo.configurator') + ->setPublic(false) + ; + $container + ->register('foo') + ->setConfigurator(array(new Reference('foo.configurator'), 'getFoo')) + ; + $this->process($container); + + $configurator = $container->getDefinition('foo')->getConfigurator(); + $this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $configurator[0]); + } + protected function process(ContainerBuilder $container) { $repeatedPass = new RepeatedPass(array(new AnalyzeServiceReferencesPass(), new InlineServiceDefinitionsPass())); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php index 2dcdf03fd4f5d..76cbb60da3938 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php @@ -145,6 +145,7 @@ public function provideCompiledContainerData() { return array( array('container8'), + array('container9'), array('container11'), array('container12'), array('container14'), diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php index 09852a4cc70b3..6addc7cbcc98c 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php @@ -37,6 +37,7 @@ public function __construct() $this->methodMap = array( 'bar' => 'getBarService', 'baz' => 'getBazService', + 'configurator_service' => 'getConfiguratorServiceService', 'configured_service' => 'getConfiguredServiceService', 'decorator_service' => 'getDecoratorServiceService', 'decorator_service_with_name' => 'getDecoratorServiceWithNameService', @@ -113,12 +114,9 @@ protected function getBazService() */ protected function getConfiguredServiceService() { - $a = new \ConfClass(); - $a->setFoo($this->get('baz')); - $this->services['configured_service'] = $instance = new \stdClass(); - $a->configureStdClass($instance); + $this->get('configurator_service')->configureStdClass($instance); return $instance; } @@ -326,6 +324,27 @@ protected function synchronizeRequestService() } } + /** + * Gets the 'configurator_service' service. + * + * This service is shared. + * This method always returns the same instance of the service. + * + * This service is private. + * If you want to be able to request this service from the container directly, + * make it public, otherwise you might end up with broken code. + * + * @return \ConfClass A ConfClass instance. + */ + protected function getConfiguratorServiceService() + { + $this->services['configurator_service'] = $instance = new \ConfClass(); + + $instance->setFoo($this->get('baz')); + + return $instance; + } + /** * Gets the 'new_factory' service. *
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: