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\DependencyInjection\ContainerBuilder;
15 use Symfony\Component\Config\Loader\Loader;
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
29 * @param ContainerBuilder $container A ContainerBuilder instance
31 public function __construct(ContainerBuilder $container)
33 $this->container = $container;
39 public function load($resource, $type = null)
41 call_user_func($resource, $this->container);
47 public function supports($resource, $type = null)
49 return $resource instanceof \Closure;