8000 bug #12570 Fix initialized() with aliased services (Daniel Wehner) · symfony/symfony@1ce8f03 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1ce8f03

Browse files
committed
bug #12570 Fix initialized() with aliased services (Daniel Wehner)
This PR was submitted for the master branch but it was merged into the 2.3 branch instead (closes #12570). Discussion ---------- Fix initialized() with aliased services | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #12569 | License | MIT | Doc PR | Commits ------- a18b6d1 Fix initialized() with aliased services
2 parents da1c1c5 + a18b6d1 commit 1ce8f03

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 if 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