|
@@ -56,6 +56,7 @@ class Container implements ContainerInterface
|
|
|
{
|
|
|
protected $parameterBag;
|
|
|
protected $services;
|
|
|
+ protected $loading = array();
|
|
|
|
|
|
/**
|
|
|
* Constructor.
|
|
@@ -183,24 +184,22 @@ class Container implements ContainerInterface
|
|
|
*/
|
|
|
public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE)
|
|
|
{
|
|
|
- static $loading = array();
|
|
|
-
|
|
|
$id = strtolower($id);
|
|
|
|
|
|
if (isset($this->services[$id])) {
|
|
|
return $this->services[$id];
|
|
|
}
|
|
|
|
|
|
- if (isset($loading[$id])) {
|
|
|
- throw new \LogicException(sprintf('Circular reference detected for service "%s" (services currently loading: %s).', $id, implode(', ', array_keys($loading))));
|
|
|
+ if (isset($this->loading[$id])) {
|
|
|
+ throw new \LogicException(sprintf('Circular reference detected for service "%s" (services currently loading: %s).', $id, implode(', ', array_keys($this->loading))));
|
|
|
}
|
|
|
|
|
|
if (method_exists($this, $method = 'get'.strtr($id, array('_' => '', '.' => '_')).'Service')) {
|
|
|
- $loading[$id] = true;
|
|
|
+ $this->loading[$id] = true;
|
|
|
|
|
|
$service = $this->$method();
|
|
|
|
|
|
- unset($loading[$id]);
|
|
|
+ unset($this->loading[$id]);
|
|
|
|
|
|
return $service;
|
|
|
}
|