Completed
Push — master ( 9c66df...e9ae83 )
by WEBEWEB
24:12
created

WBWCoreExtension   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B load() 0 32 6
1
<?php
2
3
/*
4
 * This file is part of the core-bundle package.
5
 *
6
 * (c) 2018 WEBEWEB
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 WBW\Bundle\CoreBundle\DependencyInjection;
13
14
use Symfony\Component\Config\Definition\ConfigurationInterface;
15
use Symfony\Component\Config\FileLocator;
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
use Symfony\Component\DependencyInjection\Extension\Extension;
18
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
19
20
/**
21
 * Core extension.
22
 *
23
 * @author webeweb <https://github.com/webeweb/>
24
 * @package WBW\Bundle\CoreBundle\DependencyInjection
25
 */
26
class WBWCoreExtension extends Extension {
27
28
    /**
29
     * {@inheritDoc}
30
     */
31
    public function load(array $configs, ContainerBuilder $container) {
32
33
        $fileLocator = new FileLocator(__DIR__ . "/../Resources/config");
34
35
        $serviceLoader = new YamlFileLoader($container, $fileLocator);
36
        $serviceLoader->load("services.yml");
37
38
        /** @var ConfigurationInterface $configuration */
39
        $configuration = $this->getConfiguration($configs, $container);
40
41
        $config = $this->processConfiguration($configuration, $configs);
42
43
        if (true === $config["commands"]) {
44
            $serviceLoader->load("commands.yml");
45
        }
46
47
        if (true === $config["event_listeners"]) {
48
            $serviceLoader->load("event_listeners.yml");
49
        }
50
51
        if (true === $config["providers"]) {
52
            $serviceLoader->load("providers.yml");
53
        }
54
55
        if (true === $config["security_event_listener"]) {
56
            $serviceLoader->load("services/security_event_listener.yml");
57
        }
58
59
        if (true === $config["twig"]) {
60
            $serviceLoader->load("twig.yml");
61
        }
62
    }
63
}
64