| 1 |
<?php |
| 2 |
|
| 3 |
/* |
| 4 |
* This file is part of the Symfony package. |
| 5 |
* |
| 6 |
* (c) Fabien Potencier <[email protected]> |
| 7 |
* |
| 8 |
* For the full copyright and license information, please view the LICENSE |
| 9 |
* file that was distributed with this source code. |
| 10 |
*/ |
| 11 |
namespace YoastSEO_Vendor\Symfony\Component\DependencyInjection\Argument; |
| 12 |
|
| 13 |
use YoastSEO_Vendor\Symfony\Component\DependencyInjection\ServiceLocator as BaseServiceLocator; |
| 14 |
/** |
| 15 |
* @author Nicolas Grekas <[email protected]> |
| 16 |
* |
| 17 |
* @internal |
| 18 |
*/ |
| 19 |
class ServiceLocator extends \YoastSEO_Vendor\Symfony\Component\DependencyInjection\ServiceLocator |
| 20 |
{ |
| 21 |
private $factory; |
| 22 |
private $serviceMap; |
| 23 |
private $serviceTypes; |
| 24 |
public function __construct(\Closure $factory, array $serviceMap, ?array $serviceTypes = null) |
| 25 |
{ |
| 26 |
$this->factory = $factory; |
| 27 |
$this->serviceMap = $serviceMap; |
| 28 |
$this->serviceTypes = $serviceTypes; |
| 29 |
parent::__construct($serviceMap); |
| 30 |
} |
| 31 |
/** |
| 32 |
* {@inheritdoc} |
| 33 |
* |
| 34 |
* @return mixed |
| 35 |
*/ |
| 36 |
public function get(string $id) |
| 37 |
{ |
| 38 |
return isset($this->serviceMap[$id]) ? ($this->factory)(...$this->serviceMap[$id]) : parent::get($id); |
| 39 |
} |
| 40 |
/** |
| 41 |
* {@inheritdoc} |
| 42 |
*/ |
| 43 |
public function getProvidedServices() : array |
| 44 |
{ |
| 45 |
return $this->serviceTypes ?? ($this->serviceTypes = \array_map(function () { |
| 46 |
return '?'; |
| 47 |
}, $this->serviceMap)); |
| 48 |
} |
| 49 |
} |
| 50 |
|