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

Breadcrumb

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

function CheckAliasValidityPass::process

Overrides CompilerPassInterface::process

File

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

Class

CheckAliasValidityPass
This pass validates aliases, it provides the following checks:

Namespace

Symfony\Component\DependencyInjection\Compiler

Code

public function process(ContainerBuilder $container) : void {
    foreach ($container->getAliases() as $id => $alias) {
        try {
            if (!$container->hasDefinition((string) $alias)) {
                continue;
            }
            $target = $container->getDefinition((string) $alias);
            if (null === $target->getClass() || null !== $target->getFactory()) {
                continue;
            }
            $reflection = $container->getReflectionClass($id);
            if (null === $reflection || !$reflection->isInterface()) {
                continue;
            }
            $targetReflection = $container->getReflectionClass($target->getClass());
            if (null !== $targetReflection && !$targetReflection->implementsInterface($id)) {
                throw new RuntimeException(\sprintf('Invalid alias definition: alias "%s" is referencing class "%s" but this class does not implement "%s". Because this alias is an interface, "%s" must implement "%s".', $id, $target->getClass(), $id, $target->getClass(), $id));
            }
        } catch (\ReflectionException) {
            continue;
        }
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal