public function Container::enterScope in Zircon Profile 8
Same name in this branch
- 8 vendor/symfony/dependency-injection/Container.php \Symfony\Component\DependencyInjection\Container::enterScope()
- 8 core/lib/Drupal/Component/DependencyInjection/Container.php \Drupal\Component\DependencyInjection\Container::enterScope()
Same name and namespace in other branches
- 8.0 vendor/symfony/dependency-injection/Container.php \Symfony\Component\DependencyInjection\Container::enterScope()
This is called when you enter a scope.
Parameters
string $name:
Throws
RuntimeException When the parent scope is inactive
InvalidArgumentException When the scope does not exist
Overrides ContainerInterface::enterScope
File
- vendor/
symfony/ dependency-injection/ Container.php, line 377
Class
- Container
- Container is a dependency injection container.
Namespace
Symfony\Component\DependencyInjectionCode
public function enterScope($name) {
if (!isset($this->scopes[$name])) {
throw new InvalidArgumentException(sprintf('The scope "%s" does not exist.', $name));
}
if (self::SCOPE_CONTAINER !== $this->scopes[$name] && !isset($this->scopedServices[$this->scopes[$name]])) {
throw new RuntimeException(sprintf('The parent scope "%s" must be active when entering this scope.', $this->scopes[$name]));
}
// check if a scope of this name is already active, if so we need to
// remove all services of this scope, and those of any of its child
// scopes from the global services map
if (isset($this->scopedServices[$name])) {
$services = array(
$this->services,
$name => $this->scopedServices[$name],
);
unset($this->scopedServices[$name]);
foreach ($this->scopeChildren[$name] as $child) {
if (isset($this->scopedServices[$child])) {
$services[$child] = $this->scopedServices[$child];
unset($this->scopedServices[$child]);
}
}
// update global map
$this->services = call_user_func_array('array_diff_key', $services);
array_shift($services);
// add stack entry for this scope so we can restore the removed services later
if (!isset($this->scopeStacks[$name])) {
$this->scopeStacks[$name] = new \SplStack();
}
$this->scopeStacks[$name]
->push($services);
}
$this->scopedServices[$name] = array();
}