private function ContainerBuilder::shareService

Shares a given service in the container

Parameters

Definition $definition:

mixed $service:

string $id:

Throws

InactiveScopeException

1 call to ContainerBuilder::shareService()
ContainerBuilder::createService in drupal/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerBuilder.php
Creates a service for a service definition.

File

drupal/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerBuilder.php, line 1148

Class

ContainerBuilder
ContainerBuilder is a DI container that provides an API to easily describe services.

Namespace

Symfony\Component\DependencyInjection

Code

private function shareService(Definition $definition, $service, $id) {
  if (self::SCOPE_PROTOTYPE !== ($scope = $definition
    ->getScope())) {
    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;
    }
  }
}