4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\DependencyInjection\Loader;
14 use Symfony\Component\Config\Loader\Loader;
15 use Symfony\Component\DependencyInjection\ContainerBuilder;
18 * ClosureLoader loads service definitions from a PHP closure.
20 * The Closure has access to the container as its first argument.
22 * @author Fabien Potencier <fabien@symfony.com>
24 class ClosureLoader extends Loader
28 public function __construct(ContainerBuilder $container)
30 $this->container = $container;
36 public function load($resource, $type = null)
38 \call_user_func($resource, $this->container);
44 public function supports($resource, $type = null)
46 return $resource instanceof \Closure;