public function Container::addScope in Zircon Profile 8
Same name in this branch
- 8 vendor/symfony/dependency-injection/Container.php \Symfony\Component\DependencyInjection\Container::addScope()
 - 8 core/lib/Drupal/Component/DependencyInjection/Container.php \Drupal\Component\DependencyInjection\Container::addScope()
 
Same name and namespace in other branches
- 8.0 vendor/symfony/dependency-injection/Container.php \Symfony\Component\DependencyInjection\Container::addScope()
 
Adds a scope to the container.
Parameters
ScopeInterface $scope:
Throws
Overrides ContainerInterface::addScope
File
- vendor/
symfony/ dependency-injection/ Container.php, line 468  
Class
- Container
 - Container is a dependency injection container.
 
Namespace
Symfony\Component\DependencyInjectionCode
public function addScope(ScopeInterface $scope) {
  $name = $scope
    ->getName();
  $parentScope = $scope
    ->getParentName();
  if (self::SCOPE_CONTAINER === $name || self::SCOPE_PROTOTYPE === $name) {
    throw new InvalidArgumentException(sprintf('The scope "%s" is reserved.', $name));
  }
  if (isset($this->scopes[$name])) {
    throw new InvalidArgumentException(sprintf('A scope with name "%s" already exists.', $name));
  }
  if (self::SCOPE_CONTAINER !== $parentScope && !isset($this->scopes[$parentScope])) {
    throw new InvalidArgumentException(sprintf('The parent scope "%s" does not exist, or is invalid.', $parentScope));
  }
  $this->scopes[$name] = $parentScope;
  $this->scopeChildren[$name] = array();
  // normalize the child relations
  while ($parentScope !== self::SCOPE_CONTAINER) {
    $this->scopeChildren[$parentScope][] = $name;
    $parentScope = $this->scopes[$parentScope];
  }
}