You are here

public function Container::set in Zircon Profile 8.0

Same name in this branch
  1. 8.0 vendor/symfony/dependency-injection/Container.php \Symfony\Component\DependencyInjection\Container::set()
  2. 8.0 core/lib/Drupal/Core/DependencyInjection/Container.php \Drupal\Core\DependencyInjection\Container::set()
  3. 8.0 core/lib/Drupal/Component/DependencyInjection/Container.php \Drupal\Component\DependencyInjection\Container::set()
Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/DependencyInjection/Container.php \Drupal\Core\DependencyInjection\Container::set()

Sets a service.

Parameters

string $id The service identifier:

object $service The service instance:

string $scope The scope of the service:

Overrides Container::set

File

core/lib/Drupal/Core/DependencyInjection/Container.php, line 21
Contains \Drupal\Core\DependencyInjection\Container.

Class

Container
Extends the Drupal container to set the service ID on the created object.

Namespace

Drupal\Core\DependencyInjection

Code

public function set($id, $service, $scope = ContainerInterface::SCOPE_CONTAINER) {
  parent::set($id, $service, $scope);

  // Ensure that the _serviceId property is set on synthetic services as well.
  if (isset($this->services[$id]) && is_object($this->services[$id]) && !isset($this->services[$id]->_serviceId)) {
    $this->services[$id]->_serviceId = $id;
  }
}