You are here

private function ContainerBuilder::shareService in Service Container 7.2

Same name and namespace in other branches
  1. 7 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/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 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/ContainerBuilder.php
Creates a service for a service definition.

File

modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/ContainerBuilder.php, line 1171

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