function ReverseContainer::__construct
Same name in other branches
- 10 core/lib/Drupal/Component/DependencyInjection/ReverseContainer.php \Drupal\Component\DependencyInjection\ReverseContainer::__construct()
- 11.x core/lib/Drupal/Component/DependencyInjection/ReverseContainer.php \Drupal\Component\DependencyInjection\ReverseContainer::__construct()
Constructs a ReverseContainer object.
Parameters
\Drupal\Component\DependencyInjection\Container|\Symfony\Component\DependencyInjection\Container $serviceContainer: The service container.
File
-
core/
lib/ Drupal/ Component/ DependencyInjection/ ReverseContainer.php, line 42
Class
- ReverseContainer
- Retrieves service IDs from the container for public services.
Namespace
Drupal\Component\DependencyInjectionCode
public function __construct($serviceContainer) {
if (!($serviceContainer instanceof Container || $serviceContainer instanceof SymfonyContainer)) {
throw new \InvalidArgumentException('The container must be an instance of \\Drupal\\Component\\DependencyInjection\\Container or \\Symfony\\Component\\DependencyInjection\\Container');
}
$this->serviceContainer = $serviceContainer;
$this->getServiceId = \Closure::bind(function ($service) : ?string {
return array_search($service, $this->services, TRUE) ?: NULL;
}, $serviceContainer, $serviceContainer);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.