Skip to content

Commit 39b1642

Browse files
committed
bug #17926 [DependencyInjection] Enable alias for service_container (hason)
This PR was merged into the 2.3 branch. Discussion ---------- [DependencyInjection] Enable alias for service_container | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Commits ------- 6161438 [DependencyInjection] Enabled alias for service_container
2 parents 3c3e543 + 6161438 commit 39b1642

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ public function process(ContainerBuilder $container)
4242
foreach ($container->getAliases() as $id => $alias) {
4343
$aliasId = (string) $alias;
4444

45+
if ('service_container' === $aliasId) {
46+
continue;
47+
}
48+
4549
try {
4650
$definition = $container->getDefinition($aliasId);
4751
} catch (InvalidArgumentException $e) {

src/Symfony/Component/DependencyInjection/Tests/Compiler/ReplaceAliasByActualDefinitionPassTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ public function testProcess()
3434
$container->setAlias('a_alias', 'a');
3535
$container->setAlias('b_alias', 'b');
3636

37+
$container->setAlias('container', 'service_container');
38+
3739
$this->process($container);
3840

3941
$this->assertTrue($container->has('a'), '->process() does nothing to public definitions.');
@@ -44,6 +46,7 @@ public function testProcess()
4446
'->process() replaces alias to actual.'
4547
);
4648
$this->assertSame('b_alias', $aDefinition->getFactoryService());
49+
$this->assertTrue($container->has('container'));
4750
}
4851

4952
/**

0 commit comments

Comments
 (0)