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

Breadcrumb

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

function AutowirePass::set

Associates a type and a service id if applicable.

1 call to AutowirePass::set()
AutowirePass::populateAvailableType in vendor/symfony/dependency-injection/Compiler/AutowirePass.php
Populates the list of available types for a given definition.

File

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

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 set(string $type, string $id) : void {
    // is this already a type/class that is known to match multiple services?
    if (isset($this->ambiguousServiceTypes[$type])) {
        $this->ambiguousServiceTypes[$type][] = $id;
        return;
    }
    // check to make sure the type doesn't match multiple services
    if (!isset($this->types[$type]) || $this->types[$type] === $id) {
        $this->types[$type] = $id;
        return;
    }
    // keep an array of all services matching this type
    if (!isset($this->ambiguousServiceTypes[$type])) {
        $this->ambiguousServiceTypes[$type] = [
            $this->types[$type],
        ];
        unset($this->types[$type]);
    }
    $this->ambiguousServiceTypes[$type][] = $id;
}

API Navigation

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