vendor/symfony/dependency-injection/Loader/ClosureLoader.php line 28

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\Loader;
  11. use Symfony\Component\Config\Loader\Loader;
  12. use Symfony\Component\DependencyInjection\ContainerBuilder;
  13. /**
  14.  * ClosureLoader loads service definitions from a PHP closure.
  15.  *
  16.  * The Closure has access to the container as its first argument.
  17.  *
  18.  * @author Fabien Potencier <fabien@symfony.com>
  19.  */
  20. class ClosureLoader extends Loader
  21. {
  22.     private $container;
  23.     public function __construct(ContainerBuilder $containerstring $env null)
  24.     {
  25.         $this->container $container;
  26.         parent::__construct($env);
  27.     }
  28.     /**
  29.      * {@inheritdoc}
  30.      */
  31.     public function load($resourcestring $type null)
  32.     {
  33.         return $resource($this->container$this->env);
  34.     }
  35.     /**
  36.      * {@inheritdoc}
  37.      */
  38.     public function supports($resourcestring $type null)
  39.     {
  40.         return $resource instanceof \Closure;
  41.     }
  42. }