Subversion Repositories php-qbpwcf

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 liveuser 1
<?php
2
 
3
/*
4
 * This file is part of the Symfony package.
5
 *
6
 * (c) Fabien Potencier <fabien@symfony.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
 
12
namespace Symfony\Component\Routing\Loader;
13
 
14
use Symfony\Component\Config\Loader\Loader;
15
use Symfony\Component\Routing\RouteCollection;
16
 
17
/**
18
 * ClosureLoader loads routes from a PHP closure.
19
 *
20
 * The Closure must return a RouteCollection instance.
21
 *
22
 * @author Fabien Potencier <fabien@symfony.com>
23
 */
24
class ClosureLoader extends Loader
25
{
26
    /**
27
     * Loads a Closure.
28
     *
29
     * @param \Closure    $closure A Closure
30
     * @param string|null $type    The resource type
31
     *
32
     * @return RouteCollection A RouteCollection instance
33
     */
34
    public function load($closure, string $type = null)
35
    {
36
        return $closure();
37
    }
38
 
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function supports($resource, string $type = null)
43
    {
44
        return $resource instanceof \Closure && (!$type || 'closure' === $type);
45
    }
46
}