class ServiceLocator
Same name in this branch
- 11.1.x vendor/symfony/dependency-injection/ServiceLocator.php \Symfony\Component\DependencyInjection\ServiceLocator
@author Nicolas Grekas <p@tchwork.com>
@internal
Hierarchy
- class \Symfony\Component\DependencyInjection\ServiceLocator implements \Symfony\Contracts\Service\ServiceCollectionInterface uses \Symfony\Contracts\Service\ServiceLocatorTrait
- class \Symfony\Component\DependencyInjection\Argument\ServiceLocator extends \Symfony\Component\DependencyInjection\ServiceLocator
Expanded class hierarchy of ServiceLocator
3 files declare their use of ServiceLocator
- Container.php in vendor/
symfony/ dependency-injection/ Container.php - ContainerBuilder.php in vendor/
symfony/ dependency-injection/ ContainerBuilder.php - PhpDumper.php in vendor/
symfony/ dependency-injection/ Dumper/ PhpDumper.php
File
-
vendor/
symfony/ dependency-injection/ Argument/ ServiceLocator.php, line 21
Namespace
Symfony\Component\DependencyInjection\ArgumentView source
class ServiceLocator extends BaseServiceLocator {
public function __construct(\Closure $factory, array $serviceMap, ?array $serviceTypes = null) {
parent::__construct($serviceMap);
}
public function get(string $id) : mixed {
return match (\count($this->serviceMap[$id] ?? [])) { 0 => parent::get($id),
1 => $this->serviceMap[$id][0],
default => ($this->factory)(...$this->serviceMap[$id]),
};
}
public function getProvidedServices() : array {
return $this->serviceTypes ??= array_map(fn() => '?', $this->serviceMap);
}
}