Completed
Push — master ( 69bb05...521616 )
by Benjamin
02:37
created

CMSRouteLoader::load()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

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