merged branch fabpot/deic-fix (PR #7333)
This PR was submitted for the master branch but it was merged into the 2.2 branch instead (closes #7333). Commits ------- 6992a9e [DependencyInjection] fixed id case when setting a service (also slightly enhanced an error message) Discussion ---------- [DependencyInjection] fixed id case when setting a service (also slightly enhanced an error message) | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a
This commit is contained in:
commit
02da7da5a6
@ -347,15 +347,15 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
||||
*/
|
||||
public function set($id, $service, $scope = self::SCOPE_CONTAINER)
|
||||
{
|
||||
$id = strtolower($id);
|
||||
|
||||
if ($this->isFrozen()) {
|
||||
// setting a synthetic service on a frozen container is alright
|
||||
if (!isset($this->definitions[$id]) || !$this->definitions[$id]->isSynthetic()) {
|
||||
throw new BadMethodCallException('Setting service on a frozen container is not allowed');
|
||||
throw new BadMethodCallException(sprintf('Setting service "%s" on a frozen container is not allowed.', $id));
|
||||
}
|
||||
}
|
||||
|
||||
$id = strtolower($id);
|
||||
|
||||
unset($this->definitions[$id], $this->aliases[$id]);
|
||||
|
||||
parent::set($id, $service, $scope);
|
||||
|
Reference in New Issue
Block a user