function ServiceLocatorTrait::get
1 call to ServiceLocatorTrait::get()
- ServiceLocator::get in vendor/
symfony/ dependency-injection/ ServiceLocator.php
File
-
vendor/
symfony/ service-contracts/ ServiceLocatorTrait.php, line 46
Class
- ServiceLocatorTrait
- A trait to help implement ServiceProviderInterface.
Namespace
Symfony\Contracts\ServiceCode
public function get(string $id) : mixed {
if (!isset($this->factories[$id])) {
throw $this->createNotFoundException($id);
}
if (isset($this->loading[$id])) {
$ids = array_values($this->loading);
$ids = \array_slice($this->loading, array_search($id, $ids));
$ids[] = $id;
throw $this->createCircularReferenceException($id, $ids);
}
$this->loading[$id] = $id;
try {
return $this->factories[$id]($this);
} finally {
unset($this->loading[$id]);
}
}