[DependencyInjection] ContainerBuilder: Remove obsolete definitions
This commit is contained in:
parent
8e3967dd12
commit
daa7d005ef
@ -50,11 +50,6 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|||||||
*/
|
*/
|
||||||
private $definitions = array();
|
private $definitions = array();
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Definition[]
|
|
||||||
*/
|
|
||||||
private $obsoleteDefinitions = array();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Alias[]
|
* @var Alias[]
|
||||||
*/
|
*/
|
||||||
@ -346,21 +341,8 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|||||||
{
|
{
|
||||||
$id = strtolower($id);
|
$id = strtolower($id);
|
||||||
|
|
||||||
if ($this->isFrozen()) {
|
if ($this->isFrozen() && (!isset($this->definitions[$id]) || !$this->definitions[$id]->isSynthetic())) {
|
||||||
// setting a synthetic service on a frozen container is alright
|
throw new BadMethodCallException(sprintf('Setting service "%s" for an unknown or non-synthetic service definition on a frozen container is not allowed.', $id));
|
||||||
if (
|
|
||||||
(!isset($this->definitions[$id]) && !isset($this->obsoleteDefinitions[$id]))
|
|
||||||
||
|
|
||||||
(isset($this->definitions[$id]) && !$this->definitions[$id]->isSynthetic())
|
|
||||||
||
|
|
||||||
(isset($this->obsoleteDefinitions[$id]) && !$this->obsoleteDefinitions[$id]->isSynthetic())
|
|
||||||
) {
|
|
||||||
throw new BadMethodCallException(sprintf('Setting service "%s" on a frozen container is not allowed.', $id));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($this->definitions[$id])) {
|
|
||||||
$this->obsoleteDefinitions[$id] = $this->definitions[$id];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($this->definitions[$id], $this->aliasDefinitions[$id]);
|
unset($this->definitions[$id], $this->aliasDefinitions[$id]);
|
||||||
|
Reference in New Issue
Block a user