W3cubDocs

/Drupal 8

protected function ContainerBuilder::shareService

protected ContainerBuilder::shareService(Definition $definition, $service, $id)

Direct copy of the parent function.

Overrides ContainerBuilder::shareService

File

core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php, line 178

Class

ContainerBuilder
Drupal's dependency injection container builder.

Namespace

Drupal\Core\DependencyInjection

Code

protected function shareService(Definition $definition, $service, $id) 
 {
  if ($definition->isShared() && self::SCOPE_PROTOTYPE !== $scope = $definition->getScope(false)) {
    if (self::SCOPE_CONTAINER !== $scope && !isset($this->scopedServices[$scope])) {
      throw new InactiveScopeException($id, $scope);
    }

    $this->services[$lowerId = strtolower($id)] = $service;

    if (self::SCOPE_CONTAINER !== $scope) {
      $this->scopedServices[$scope][$lowerId] = $service;
    }
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!DependencyInjection!ContainerBuilder.php/function/ContainerBuilder::shareService/8.1.x