function Container::reset
Same name and namespace in other branches
- 11.x core/lib/Drupal/Component/DependencyInjection/Container.php \Drupal\Component\DependencyInjection\Container::reset()
- 10 core/lib/Drupal/Component/DependencyInjection/Container.php \Drupal\Component\DependencyInjection\Container::reset()
- 9 core/lib/Drupal/Component/DependencyInjection/Container.php \Drupal\Component\DependencyInjection\Container::reset()
- 8.9.x core/lib/Drupal/Component/DependencyInjection/Container.php \Drupal\Component\DependencyInjection\Container::reset()
Resets shared services from the container.
The container is not intended to be used again after being reset in a normal workflow. This method is meant as a way to release references for ref-counting. A subsequent call to ContainerInterface::get() will recreate a new instance of the shared service.
File
-
core/
lib/ Drupal/ Component/ DependencyInjection/ Container.php, line 206
Class
- Container
- Provides a container optimized for Drupal's needs.
Namespace
Drupal\Component\DependencyInjectionCode
public function reset() : void {
$this->privateServices = [];
foreach (array_keys($this->services) as $id) {
if ($id === 'request_stack') {
continue;
}
$definition = $this->serviceDefinitions[$id] ?? NULL;
// Definitions can either be a keyed array or a serialized string.
if (is_string($definition)) {
$definition = unserialize($definition);
}
if (!isset($definition['synthetic']) || $definition['synthetic'] === FALSE) {
unset($this->services[$id]);
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.