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

Breadcrumb

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

function ResolveServiceSubscribersPass::processValue

Overrides AbstractRecursivePass::processValue

File

vendor/symfony/dependency-injection/Compiler/ResolveServiceSubscribersPass.php, line 30

Class

ResolveServiceSubscribersPass
Compiler pass to inject their service locator to service subscribers.

Namespace

Symfony\Component\DependencyInjection\Compiler

Code

protected function processValue(mixed $value, bool $isRoot = false) : mixed {
    if ($value instanceof Reference && $this->serviceLocator && \in_array((string) $value, [
        ContainerInterface::class,
        ServiceProviderInterface::class,
    ], true)) {
        return new Reference($this->serviceLocator);
    }
    if (!$value instanceof Definition) {
        return parent::processValue($value, $isRoot);
    }
    $serviceLocator = $this->serviceLocator;
    $this->serviceLocator = null;
    if ($value->hasTag('container.service_subscriber.locator')) {
        $this->serviceLocator = $value->getTag('container.service_subscriber.locator')[0]['id'];
        $value->clearTag('container.service_subscriber.locator');
    }
    try {
        return parent::processValue($value);
    } finally {
        $this->serviceLocator = $serviceLocator;
    }
}
RSS feed
Powered by Drupal