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

CMSRouteLoader   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 28
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A load() 0 18 2
A supports() 0 4 1
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