Completed
Pull Request — master (#20)
by Wachter
04:58
created

TaskExtension::load()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 2.0185

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 10
cts 12
cp 0.8333
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 10
nc 2
nop 2
crap 2.0185
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 15
    public function load(array $configs, ContainerBuilder $container)
28
    {
29 15
        $configuration = new Configuration();
30 15
        $config = $this->processConfiguration($configuration, $configs);
31
32 15
        $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
33 15
        $loader->load(sprintf('storage/%s.xml', $config['storage']));
34 15
        $loader->load('task_event_listener.xml');
35 15
        $loader->load('scheduler.xml');
36 15
        $loader->load('command.xml');
37
38 15
        if ($config['run']['mode'] === 'listener') {
39
            $loader->load('listener.xml');
40
        }
41 15
    }
42
}
43