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

Breadcrumb

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

class ResolveServiceSubscribersPass

Compiler pass to inject their service locator to service subscribers.

@author Nicolas Grekas <p@tchwork.com>

Hierarchy

  • class \Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass implements \Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface
    • class \Symfony\Component\DependencyInjection\Compiler\ResolveServiceSubscribersPass extends \Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass

Expanded class hierarchy of ResolveServiceSubscribersPass

File

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

Namespace

Symfony\Component\DependencyInjection\Compiler
View source
class ResolveServiceSubscribersPass extends AbstractRecursivePass {
    protected bool $skipScalars = true;
    private ?string $serviceLocator = null;
    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;
        }
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
AbstractRecursivePass::$container protected property
AbstractRecursivePass::$currentId protected property
AbstractRecursivePass::$expressionLanguage private property 1
AbstractRecursivePass::$inExpression private property
AbstractRecursivePass::$processExpressions private property
AbstractRecursivePass::enableExpressionProcessing protected function
AbstractRecursivePass::getConstructor protected function
AbstractRecursivePass::getExpressionLanguage private function 1
AbstractRecursivePass::getReflectionMethod protected function
AbstractRecursivePass::inExpression protected function
AbstractRecursivePass::process public function Overrides CompilerPassInterface::process 15
ResolveServiceSubscribersPass::$serviceLocator private property
ResolveServiceSubscribersPass::$skipScalars protected property Overrides AbstractRecursivePass::$skipScalars
ResolveServiceSubscribersPass::processValue protected function Processes a value found in a definition tree. Overrides AbstractRecursivePass::processValue
RSS feed
Powered by Drupal