function ReverseContainer::getService
Throws
ServiceNotFoundException When the service is not reversible
File
-
vendor/
symfony/ dependency-injection/ ReverseContainer.php, line 59
Class
- ReverseContainer
- Turns public and "container.reversible" services back to their ids.
Namespace
Symfony\Component\DependencyInjectionCode
public function getService(string $id) : object {
if ($this->reversibleLocator
->has($id)) {
return $this->reversibleLocator
->get($id);
}
if (isset($this->serviceContainer
->getRemovedIds()[$id])) {
throw new ServiceNotFoundException($id, null, null, [], \sprintf('The "%s" service is private and cannot be accessed by reference. You should either make it public, or tag it as "%s".', $id, $this->tagName));
}
return $this->serviceContainer
->get($id);
}