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

Breadcrumb

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

function CheckReferenceValidityPass::processValue

Overrides AbstractRecursivePass::processValue

File

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

Class

CheckReferenceValidityPass
Checks the validity of references.

Namespace

Symfony\Component\DependencyInjection\Compiler

Code

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