SpomkyLabsRoleHierarchyExtension   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 6
dl 0
loc 40
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getAlias() 0 4 1
A load() 0 13 1
1
<?php
2
3
/*
4
 * The MIT License (MIT)
5
 *
6
 * Copyright (c) 2014-2016 Spomky-Labs
7
 *
8
 * This software may be modified and distributed under the terms
9
 * of the MIT license.  See the LICENSE file for details.
10
 */
11
12
namespace SpomkyLabs\RoleHierarchyBundle\DependencyInjection;
13
14
use Symfony\Component\Config\Definition\Processor;
15
use Symfony\Component\Config\FileLocator;
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
18
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
19
20
final class SpomkyLabsRoleHierarchyExtension extends Extension
21
{
22
    /**
23
     * @var string
24
     */
25
    private $alias;
26
27
    /**
28
     * @param string $alias
29
     */
30
    public function __construct($alias)
31
    {
32
        $this->alias = $alias;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function getAlias()
39
    {
40
        return $this->alias;
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function load(array $configs, ContainerBuilder $container)
47
    {
48
        $processor = new Processor();
49
        $configuration = new Configuration();
50
51
        $config = $processor->processConfiguration($configuration, $configs);
52
53
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
54
        $loader->load('services.xml');
55
56
        $container->setAlias($this->getAlias().'.role_manager', $config['role_manager']);
57
        $container->setParameter($this->getAlias().'.role_class', $config['role_class']);
58
    }
59
}
60