CMSRouteLoader::supports()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace Alpixel\Bundle\CMSBundle\Routing;
4
5
use Symfony\Component\Config\Loader\Loader;
6
use Symfony\Component\Routing\RouteCollection;
7
8
/**
9
 * @author Benjamin HUBERT <[email protected]>
10
 */
11
class CMSRouteLoader extends Loader
12
{
13
    private $loaded = false;
14
15
    public function load($resource, $type = null)
16
    {
17
        if (true === $this->loaded) {
18
            throw new \RuntimeException('Do not add the "alpixel_cms" loader twice');
19
        }
20
21
        $collection = new RouteCollection();
22
23
        $resource = '@AlpixelCMSBundle/Resources/config/routing.yml';
24
        $type = 'yaml';
25
26
        $importedRoutes = $this->import($resource, $type);
27
        $collection->addCollection($importedRoutes);
28
29
        $this->loaded = true;
30
31
        return $collection;
32
    }
33
34
    public function supports($resource, $type = null)
35
    {
36
        return 'alpixel_cms' === $type;
37
    }
38
}
39