function Container::set

Same name in this branch
  1. 8.9.x core/lib/Drupal/Component/DependencyInjection/Container.php \Drupal\Component\DependencyInjection\Container::set()
Same name in other branches
  1. 9 core/lib/Drupal/Component/DependencyInjection/Container.php \Drupal\Component\DependencyInjection\Container::set()
  2. 10 core/lib/Drupal/Component/DependencyInjection/Container.php \Drupal\Component\DependencyInjection\Container::set()
  3. 11.x core/lib/Drupal/Component/DependencyInjection/Container.php \Drupal\Component\DependencyInjection\Container::set()

Overrides Container::set

File

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

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) {
    parent::set($id, $service);
    // 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;
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.