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\CompilerCode
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;
}