AbstractArgument.php
4 years ago
ArgumentInterface.php
4 years ago
BoundArgument.php
2 years ago
IteratorArgument.php
4 years ago
ReferenceSetArgumentTrait.php
4 years ago
RewindableGenerator.php
4 years ago
ServiceClosureArgument.php
4 years ago
ServiceLocator.php
2 years ago
ServiceLocatorArgument.php
4 years ago
TaggedIteratorArgument.php
2 years ago
index.php
3 years ago
ServiceLocator.php
28 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Symfony\Component\DependencyInjection\Argument; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | use MailPoetVendor\Symfony\Component\DependencyInjection\ServiceLocator as BaseServiceLocator; |
| 5 | class ServiceLocator extends BaseServiceLocator |
| 6 | { |
| 7 | private $factory; |
| 8 | private $serviceMap; |
| 9 | private $serviceTypes; |
| 10 | public function __construct(\Closure $factory, array $serviceMap, ?array $serviceTypes = null) |
| 11 | { |
| 12 | $this->factory = $factory; |
| 13 | $this->serviceMap = $serviceMap; |
| 14 | $this->serviceTypes = $serviceTypes; |
| 15 | parent::__construct($serviceMap); |
| 16 | } |
| 17 | public function get(string $id) |
| 18 | { |
| 19 | return isset($this->serviceMap[$id]) ? ($this->factory)(...$this->serviceMap[$id]) : parent::get($id); |
| 20 | } |
| 21 | public function getProvidedServices() : array |
| 22 | { |
| 23 | return $this->serviceTypes ?? ($this->serviceTypes = \array_map(function () { |
| 24 | return '?'; |
| 25 | }, $this->serviceMap)); |
| 26 | } |
| 27 | } |
| 28 |