ItkgDelayEventExtension::loadChannels()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
crap 2
1
<?php
2
3
namespace Itkg\DelayEventBundle\DependencyInjection;
4
5
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
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
 * This is the class that loads and manages your bundle configuration
13
 *
14
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
15
 */
16
class ItkgDelayEventExtension extends Extension
17
{
18
    /**
19
     * {@inheritdoc}
20
     */
21
    public function load(array $configs, ContainerBuilder $container)
22
    {
23
        $configuration = new Configuration();
24
        $config = $this->processConfiguration($configuration, $configs);
25
26
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
27
        $loader->load('services.yml');
28
29
        $this->loadEventNames($container, $config);
30
        $this->loadProcessorConfiguration($container, $config);
31
        $this->loadChannels($container, $config);
32
    }
33
34
    /**
35
     * @param ContainerBuilder $container
36
     * @param array            $config
37
     */
38
    protected function loadEventNames(ContainerBuilder $container, array $config)
39
    {
40
        if (isset($config['events'])) {
41
            $container->setParameter('itkg_delay_event.event_names', array_keys($config['events']));
42
            $container->setParameter('itkg_delay_event.event_config', $config['events']);
43
        }
44
    }
45
46
    /**
47
     * @param ContainerBuilder $container
48
     * @param array            $config
49
     */
50
    protected function loadProcessorConfiguration(ContainerBuilder $container, array $config)
51
    {
52
        $container->setParameter('itkg_delay_event.processor.config', $config['processor']);
53
    }
54
55
    /**
56
     * @param ContainerBuilder $container
57
     * @param array            $config
58
     */
59
    private function loadChannels(ContainerBuilder $container, array $config)
60
    {
61
        $container->setParameter('itkg_delay_event.channels', $config['channels']);
62
    }
63
}
64