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

Breadcrumb

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

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\DependencyInjection

Code

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);
}
RSS feed
Powered by Drupal