This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/DependencyInjection/Loader/ClosureLoader.php

45 lines
1.0 KiB
PHP
Raw Normal View History

<?php
namespace Symfony\Component\DependencyInjection\Loader;
/*
* This file is part of the Symfony framework.
*
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
/**
* ClosureLoader loads service definitions from a PHP closure.
*
* The Closure has access to the container as its first argument.
*
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
*/
class ClosureLoader extends Loader
{
/**
* Loads a Closure.
*
* @param \Closure $resource The resource
*/
public function load($closure)
{
call_user_func($closure, $this->container);
}
/**
* Returns true if this class supports the given resource.
*
* @param mixed $resource A resource
*
* @return Boolean true if this class supports the given resource, false otherwise
*/
public function supports($resource)
{
return $resource instanceof \Closure;
}
}