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\Routing\Loader
;
14 use Symfony\Component\Config\Loader\Loader
;
15 use Symfony\Component\Routing\RouteCollection
;
18 * ClosureLoader loads routes from a PHP closure.
20 * The Closure must return a RouteCollection instance.
22 * @author Fabien Potencier <fabien@symfony.com>
26 class ClosureLoader
extends Loader
31 * @param \Closure $closure A Closure
32 * @param string|null $type The resource type
34 * @return RouteCollection A RouteCollection instance
38 public function load($closure, $type = null)
40 return call_user_func($closure);
48 public function supports($resource, $type = null)
50 return $resource instanceof \Closure
&& (!$type || 'closure' === $type);