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

Breadcrumb

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

function AutowirePass::getCombinedAlias

1 call to AutowirePass::getCombinedAlias()
AutowirePass::getAutowiredReference in vendor/symfony/dependency-injection/Compiler/AutowirePass.php
Returns a reference to the service matching the given type, if any.

File

vendor/symfony/dependency-injection/Compiler/AutowirePass.php, line 723

Class

AutowirePass
Inspects existing service definitions and wires the autowired ones using the type hints of their classes.

Namespace

Symfony\Component\DependencyInjection\Compiler

Code

private function getCombinedAlias(string $type, ?string $name = null) : ?string {
    if (str_contains($type, '&')) {
        $types = explode('&', $type);
    }
    elseif (str_contains($type, '|')) {
        $types = explode('|', $type);
    }
    else {
        return null;
    }
    $alias = null;
    $suffix = $name ? ' $' . $name : '';
    foreach ($types as $type) {
        if (!$this->container
            ->hasAlias($type . $suffix)) {
            return null;
        }
        if (null === $alias) {
            $alias = (string) $this->container
                ->getAlias($type . $suffix);
        }
        elseif ((string) $this->container
            ->getAlias($type . $suffix) !== $alias) {
            return null;
        }
    }
    return $alias;
}

API Navigation

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