[DI] Aliases should preserve the aliased invalid behavior
This commit is contained in:
parent
30d161c0ae
commit
7752308c96
@ -430,7 +430,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!array_key_exists($id, $this->definitions) && isset($this->aliasDefinitions[$id])) {
|
if (!array_key_exists($id, $this->definitions) && isset($this->aliasDefinitions[$id])) {
|
||||||
return $this->get($this->aliasDefinitions[$id]);
|
return $this->get($this->aliasDefinitions[$id], $invalidBehavior);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -231,6 +231,18 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertSame($foo, $builder->get('alias'), '->set() replaces an existing alias');
|
$this->assertSame($foo, $builder->get('alias'), '->set() replaces an existing alias');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testAliasesKeepInvalidBehavior()
|
||||||
|
{
|
||||||
|
$builder = new ContainerBuilder();
|
||||||
|
|
||||||
|
$aliased = new Definition('stdClass');
|
||||||
|
$aliased->addMethodCall('setBar', array(new Reference('bar', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)));
|
||||||
|
$builder->setDefinition('aliased', $aliased);
|
||||||
|
$builder->setAlias('alias', 'aliased');
|
||||||
|
|
||||||
|
$this->assertEquals(new \stdClass(), $builder->get('alias'));
|
||||||
|
}
|
||||||
|
|
||||||
public function testAddGetCompilerPass()
|
public function testAddGetCompilerPass()
|
||||||
{
|
{
|
||||||
$builder = new ContainerBuilder();
|
$builder = new ContainerBuilder();
|
||||||
|
Reference in New Issue
Block a user