public function Container::leaveScope in Zircon Profile 8
Same name in this branch
- 8 vendor/symfony/dependency-injection/Container.php \Symfony\Component\DependencyInjection\Container::leaveScope()
- 8 core/lib/Drupal/Component/DependencyInjection/Container.php \Drupal\Component\DependencyInjection\Container::leaveScope()
Same name and namespace in other branches
- 8.0 vendor/symfony/dependency-injection/Container.php \Symfony\Component\DependencyInjection\Container::leaveScope()
This is called to leave the current scope, and move back to the parent scope.
Parameters
string $name The name of the scope to leave:
Throws
InvalidArgumentException if the scope is not active
Overrides ContainerInterface::leaveScope
File
- vendor/
symfony/ dependency-injection/ Container.php, line 423
Class
- Container
- Container is a dependency injection container.
Namespace
Symfony\Component\DependencyInjectionCode
public function leaveScope($name) {
if (!isset($this->scopedServices[$name])) {
throw new InvalidArgumentException(sprintf('The scope "%s" is not active.', $name));
}
// remove all services of this scope, or any of its child scopes from
// the global service map
$services = array(
$this->services,
$this->scopedServices[$name],
);
unset($this->scopedServices[$name]);
foreach ($this->scopeChildren[$name] as $child) {
if (isset($this->scopedServices[$child])) {
$services[] = $this->scopedServices[$child];
unset($this->scopedServices[$child]);
}
}
// update global map
$this->services = call_user_func_array('array_diff_key', $services);
// check if we need to restore services of a previous scope of this type
if (isset($this->scopeStacks[$name]) && count($this->scopeStacks[$name]) > 0) {
$services = $this->scopeStacks[$name]
->pop();
$this->scopedServices += $services;
if ($this->scopeStacks[$name]
->isEmpty()) {
unset($this->scopeStacks[$name]);
}
foreach ($services as $array) {
foreach ($array as $id => $service) {
$this
->set($id, $service, $name);
}
}
}
}