Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: namespace Symfony\Component\Routing\Loader; Chris@0: Chris@0: use Symfony\Component\Config\Loader\Loader; Chris@0: use Symfony\Component\Routing\RouteCollection; Chris@0: Chris@0: /** Chris@0: * ClosureLoader loads routes from a PHP closure. Chris@0: * Chris@0: * The Closure must return a RouteCollection instance. Chris@0: * Chris@0: * @author Fabien Potencier Chris@0: */ Chris@0: class ClosureLoader extends Loader Chris@0: { Chris@0: /** Chris@0: * Loads a Closure. Chris@0: * Chris@0: * @param \Closure $closure A Closure Chris@0: * @param string|null $type The resource type Chris@0: * Chris@0: * @return RouteCollection A RouteCollection instance Chris@0: */ Chris@0: public function load($closure, $type = null) Chris@0: { Chris@0: return $closure(); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function supports($resource, $type = null) Chris@0: { Chris@0: return $resource instanceof \Closure && (!$type || 'closure' === $type); Chris@0: } Chris@0: }