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>
24 class ClosureLoader extends Loader
29 * @param \Closure $closure A Closure
30 * @param string|null $type The resource type
32 * @return RouteCollection A RouteCollection instance
34 public function load($closure, $type = null)
42 public function supports($resource, $type = null)
44 return $resource instanceof \Closure && (!$type || 'closure' === $type);