BlackEmailExtension   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 32
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A load() 0 18 3
A getAlias() 0 4 1
1
<?php
2
3
namespace Black\Bundle\EmailBundle\Application\DependencyInjection;
4
5
use Symfony\Component\Config\Definition\Processor;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\Config\FileLocator;
8
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
9
use Symfony\Component\DependencyInjection\Loader;
10
11
/**
12
 * Class BlackEmailExtension
13
 *
14
 * This is the class that loads and manages your bundle configuration
15
 *
16
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
17
 *
18
 * @license http://opensource.org/licenses/mit-license.php MIT
19
 */
20
class BlackEmailExtension extends Extension
21
{
22
    /**
23
     * {@inheritDoc}
24
     */
25
    public function load(array $configs, ContainerBuilder $container)
26
    {
27
        $processor = new Processor();
28
        $configuration = new Configuration($this->getAlias());
29
        $config = $processor->processConfiguration($configuration, $configs);
30
31
        $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../../Resources/config'));
32
33
        if (!isset($config['db_driver'])) {
34
            throw new \InvalidArgumentException('You must provide the black_user.db_driver configuration');
35
        }
36
37
        $container->setParameter($this->getAlias() . '.backend_type_' . $config['db_driver'], true);
38
39
        foreach ([] as $service) {
40
            $loader->load(sprintf('%s.xml', $service));
41
        }
42
    }
43
44
    /**
45
     * @return string
46
     */
47
    public function getAlias()
48
    {
49
        return 'black_email';
50
    }
51
}
52