function ReverseContainer::__construct

Same name in other branches
  1. 9 core/lib/Drupal/Component/DependencyInjection/ReverseContainer.php \Drupal\Component\DependencyInjection\ReverseContainer::__construct()
  2. 10 core/lib/Drupal/Component/DependencyInjection/ReverseContainer.php \Drupal\Component\DependencyInjection\ReverseContainer::__construct()

Constructs a ReverseContainer object.

Parameters

\Drupal\Component\DependencyInjection\Container|\Symfony\Component\DependencyInjection\Container $serviceContainer: The service container.

File

core/lib/Drupal/Component/DependencyInjection/ReverseContainer.php, line 35

Class

ReverseContainer
Retrieves service IDs from the container for public services.

Namespace

Drupal\Component\DependencyInjection

Code

public function __construct(Container|SymfonyContainer $serviceContainer) {
    $this->getServiceId = \Closure::bind(function ($service) : ?string {
        return array_search($service, $this->services, TRUE) ?: NULL;
    }, $serviceContainer, $serviceContainer);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.