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
This commit is contained in:
commit
1ce8f03040
@ -365,6 +365,10 @@ class Container implements IntrospectableContainerInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isset($this->aliases[$id])) {
|
||||
$id = $this->aliases[$id];
|
||||
}
|
||||
|
||||
return isset($this->services[$id]) || array_key_exists($id, $this->services);
|
||||
}
|
||||
|
||||
|
@ -272,6 +272,10 @@ class ContainerTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertTrue($sc->initialized('foo'), '->initialized() returns true if service is loaded');
|
||||
$this->assertFalse($sc->initialized('foo1'), '->initialized() returns false if service is not loaded');
|
||||
$this->assertFalse($sc->initialized('bar'), '->initialized() returns false if a service is defined, but not currently loaded');
|
||||
$this->assertFalse($sc->initialized('alias'), '->initialized() returns false if an aliased service is not initialized');
|
||||
|
||||
$sc->set('bar', new \stdClass());
|
||||
$this->assertTrue($sc->initialized('alias'), '->initialized() returns true for alias if aliased service is initialized');
|
||||
}
|
||||
|
||||
public function testEnterLeaveCurrentScope()
|
||||
|
Reference in New Issue
Block a user