10000 Fix initialized() with aliased services · symfony/symfony@a18b6d1 · GitHub
[go: up one dir, main page]

Skip to content

Commit a18b6d1

Browse files
dawehnerfabpot
authored andcommitted
Fix initialized() with aliased services
1 parent da1c1c5 commit a18b6d1

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/Symfony/Component/DependencyInjection/Container.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,10 @@ public function initialized($id)
365365
return true;
366366
}
367367

368+
if (isset($this->aliases[$id])) {
369+
$id = $this->aliases[$id];
370+
}
371+
368372
return isset($this->services[$id]) || array_key_exists($id, $this->services);
369373
}
370374

src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,10 @@ public function testInitialized()
272272
$this->assertTrue($sc->initialized('foo'), '->initialized() returns true if service is loaded');
273273
$this->assertFalse($sc->initialized('foo1'), '->initialized() returns false i 684C f service is not loaded');
274274
$this->assertFalse($sc->initialized('bar'), '->initialized() returns false if a service is defined, but not currently loaded');
275+
$this->assertFalse($sc->initialized('alias'), '->initialized() returns false if an aliased service is not initialized');
276+
277+
$sc->set('bar', new \stdClass());
278+
$this->assertTrue($sc->initialized('alias'), '->initialized() returns true for alias if aliased service is initialized');
275279
}
276280

277281
public function testEnterLeaveCurrentScope()

0 commit comments

Comments
 (0)
0