Completed
Pull Request — master (#20)
by Wachter
05:26
created

TaskExtension   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 21
ccs 10
cts 12
cp 0.8333
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A load() 0 15 2
1
<?php
2
3
/*
4
 * This file is part of php-task library.
5
 *
6
 * (c) php-task
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Task\TaskBundle\DependencyInjection;
13
14
use Symfony\Component\Config\FileLocator;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Loader;
17
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
18
19
/**
20
 * Container extension for php-task library.
21
 */
22
class TaskExtension extends Extension
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27 12
    public function load(array $configs, ContainerBuilder $container)
28
    {
29 12
        $configuration = new Configuration();
30 12
        $config = $this->processConfiguration($configuration, $configs);
31
32 12
        $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
33 12
        $loader->load(sprintf('storage/%s.xml', $config['storage']));
34 12
        $loader->load('task_event_listener.xml');
35 12
        $loader->load('scheduler.xml');
36 12
        $loader->load('command.xml');
37
38 12
        if ($config['run']['mode'] === 'listener') {
39
            $loader->load('listener.xml');
40
        }
41 12
    }
42
}
43