fixed id case when setting a service (also slightly enhanced an error message)

This commit is contained in:
Fabien Potencier 2013-03-11 22:43:32 +01:00
parent cf29581cb2
commit 639c30c9be

View File

@ -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);