W3cubDocs

/Drupal 8

public function Container::set

public Container::set($id, $service, $scope = ContainerInterface::SCOPE_CONTAINER)

Overrides Container::set

File

core/lib/Drupal/Core/DependencyInjection/Container.php, line 16

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

© 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!Container.php/function/Container::set/8.1.x