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

Breadcrumb

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

class CheckReferenceValidityPass

Checks the validity of references.

The following checks are performed by this pass:

  • target definitions are not abstract

@author Johannes M. Schmitt <schmittjoh@gmail.com>

Hierarchy

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

Expanded class hierarchy of CheckReferenceValidityPass

File

vendor/symfony/dependency-injection/Compiler/CheckReferenceValidityPass.php, line 26

Namespace

Symfony\Component\DependencyInjection\Compiler
View source
class CheckReferenceValidityPass extends AbstractRecursivePass {
    protected bool $skipScalars = true;
    protected function processValue(mixed $value, bool $isRoot = false) : mixed {
        if ($isRoot && $value instanceof Definition && ($value->isSynthetic() || $value->isAbstract())) {
            return $value;
        }
        if ($value instanceof Reference && $this->container
            ->hasDefinition((string) $value)) {
            $targetDefinition = $this->container
                ->getDefinition((string) $value);
            if ($targetDefinition->isAbstract()) {
                throw new RuntimeException(\sprintf('The definition "%s" has a reference to an abstract definition "%s". Abstract definitions cannot be the target of references.', $this->currentId, $value));
            }
        }
        return parent::processValue($value, $isRoot);
    }

}

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
CheckReferenceValidityPass::$skipScalars protected property Overrides AbstractRecursivePass::$skipScalars
CheckReferenceValidityPass::processValue protected function Processes a value found in a definition tree. Overrides AbstractRecursivePass::processValue
RSS feed
Powered by Drupal