[DependencyInjection] Prevented inlining of lazy loaded private service definitions.
This commit is contained in:
parent
9a65ce3886
commit
bb0125b2f9
@ -117,7 +117,7 @@ class InlineServiceDefinitionsPass implements RepeatablePassInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($definition->isPublic()) {
|
||||
if ($definition->isPublic() || $definition->isLazy()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -12,10 +12,8 @@
|
||||
namespace Symfony\Component\DependencyInjection\Tests\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Scope;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Compiler\AnalyzeServiceReferencesPass;
|
||||
use Symfony\Component\DependencyInjection\Compiler\Compiler;
|
||||
use Symfony\Component\DependencyInjection\Compiler\RepeatedPass;
|
||||
use Symfony\Component\DependencyInjection\Compiler\InlineServiceDefinitionsPass;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
@ -126,6 +124,26 @@ class InlineServiceDefinitionsPassTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertTrue($container->hasDefinition('a'));
|
||||
}
|
||||
|
||||
public function testProcessDoesNotInlineWhenServiceIsPrivateButLazy()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container
|
||||
->register('foo')
|
||||
->setPublic(false)
|
||||
->setLazy(true)
|
||||
;
|
||||
|
||||
$container
|
||||
->register('service')
|
||||
->setArguments(array($ref = new Reference('foo')))
|
||||
;
|
||||
|
||||
$this->process($container);
|
||||
|
||||
$arguments = $container->getDefinition('service')->getArguments();
|
||||
$this->assertSame($ref, $arguments[0]);
|
||||
}
|
||||
|
||||
protected function process(ContainerBuilder $container)
|
||||
{
|
||||
$repeatedPass = new RepeatedPass(array(new AnalyzeServiceReferencesPass(), new InlineServiceDefinitionsPass()));
|
||||
|
Reference in New Issue
Block a user