vendor/symfony/dependency-injection/Argument/ServiceLocator.php line 38

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\DependencyInjection\Argument;
  11. use Symfony\Component\DependencyInjection\ServiceLocator as BaseServiceLocator;
  12. /**
  13.  * @author Nicolas Grekas <p@tchwork.com>
  14.  *
  15.  * @internal
  16.  */
  17. class ServiceLocator extends BaseServiceLocator
  18. {
  19.     private $factory;
  20.     private $serviceMap;
  21.     public function __construct(\Closure $factory, array $serviceMap)
  22.     {
  23.         $this->factory $factory;
  24.         $this->serviceMap $serviceMap;
  25.         parent::__construct($serviceMap);
  26.     }
  27.     /**
  28.      * {@inheritdoc}
  29.      */
  30.     public function get($id)
  31.     {
  32.         return isset($this->serviceMap[$id]) ? ($this->factory)(...$this->serviceMap[$id]) : parent::get($id);
  33.     }
  34. }