You are here

private function ContainerBuilder::shareService in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/dependency-injection/ContainerBuilder.php \Symfony\Component\DependencyInjection\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 vendor/symfony/dependency-injection/ContainerBuilder.php
Creates a service for a service definition.

File

vendor/symfony/dependency-injection/ContainerBuilder.php, line 1103

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;
    }
  }
}