function Container::getService
@internal
File
-
vendor/
symfony/ dependency-injection/ Container.php, line 379
Class
- Container
- Container is a dependency injection container.
Namespace
Symfony\Component\DependencyInjectionCode
protected final function getService(string|false $registry, string $id, ?string $method, string|bool $load) : mixed {
if ('service_container' === $id) {
return $this;
}
if (\is_string($load)) {
throw new RuntimeException($load);
}
if (null === $method) {
return false !== $registry ? $this->{$registry}[$id] ?? null : null;
}
if (false !== $registry) {
return $this->{$registry}[$id] ??= $load ? $this->load($method) : $this->{$method}($this);
}
if (!$load) {
return $this->{$method}($this);
}
return ($factory = $this->factories[$id] ?? $this->factories['service_container'][$id] ?? null) ? $factory($this) : $this->load($method);
}