Permalink
Browse files

[DependencyInjection] fixed #8570

  • Loading branch information...
bronze1man committed Jul 25, 2013
1 parent 2e2a36c commit 970ce2c413fb8f2541828eea1ad06d5ca5e08be1
@@ -87,6 +87,7 @@ private function resolveDefinition($id, DefinitionDecorator $definition)
$def->setConfigurator($parentDef->getConfigurator());
$def->setFile($parentDef->getFile());
$def->setPublic($parentDef->isPublic());
$def->setLazy($parentDef->isLazy());
// overwrite with values specified in the decorator
$changes = $definition->getChanges();
@@ -111,6 +112,9 @@ private function resolveDefinition($id, DefinitionDecorator $definition)
if (isset($changes['public'])) {
$def->setPublic($definition->isPublic());
}
if (isset($changes['lazy'])){
$def->setLazy($definition->isLazy());
}
// merge arguments
foreach ($definition->getArguments() as $k => $v) {
@@ -149,6 +149,18 @@ public function setPublic($boolean)
return parent::setPublic($boolean);
}
/**
* {@inheritDoc}
*
* @api
*/
public function setLazy($boolean)
{
$this->changes['lazy'] = true;
return parent::setLazy($boolean);
}
/**
* Gets an argument to pass to the service constructor/factory method.
*
@@ -143,6 +143,36 @@ public function testProcessHandlesMultipleInheritance()
$this->assertEquals('foo', $def->getClass());
}
public function testSetLazyOnServiceHasParent()
{
$container = new ContainerBuilder();
$container->register('parent','stdClass');
$container->setDefinition('child1',new DefinitionDecorator('parent'))
->setLazy(true)
;
$this->process($container);
$this->assertTrue($container->getDefinition('child1')->isLazy());
}
public function testSetLazyOnServiceIsParent()
{
$container = new ContainerBuilder();
$container->register('parent','stdClass')
->setLazy(true)
;
$container->setDefinition('child1',new DefinitionDecorator('parent'));
$this->process($container);
$this->assertTrue($container->getDefinition('child1')->isLazy());
}
protected function process(ContainerBuilder $container)
{
$pass = new ResolveDefinitionTemplatesPass();
@@ -61,6 +61,16 @@ public function testSetPublic()
$this->assertEquals(array('public' => true), $def->getChanges());
}
public function testSetLazy()
{
$def = new DefinitionDecorator('foo');
$this->assertFalse($def->isLazy());
$this->assertSame($def, $def->setLazy(false));
$this->assertFalse($def->isLazy());
$this->assertEquals(array('lazy' => true), $def->getChanges());
}
public function testSetArgument()
{
$def = new DefinitionDecorator('foo');

0 comments on commit 970ce2c

Please sign in to comment.