Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Container.php

function Container::getService

@internal

File

vendor/symfony/dependency-injection/Container.php, line 379

Class

Container
Container is a dependency injection container.

Namespace

Symfony\Component\DependencyInjection

Code

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);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal