QuerySortingExtension::load()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 21
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 12
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 21
rs 9.8666
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Bugloos\QuerySortingBundle\DependencyInjection;
6
7
use http\Exception\RuntimeException;
8
use Symfony\Component\Config\FileLocator;
9
use Symfony\Component\DependencyInjection\ContainerBuilder;
10
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
11
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
12
13
/**
14
 * @author Milad Ghofrani <[email protected]>
15
 */
16
class QuerySortingExtension extends Extension
17
{
18
    public function load(array $configs, ContainerBuilder $container)
19
    {
20
        $configuration = $this->getConfiguration($configs, $container);
21
22
        if (!isset($configuration) || empty($configuration)) {
23
            throw new RuntimeException(
24
                'The configuration is not set correctly'
25
            );
26
        }
27
28
        $config = $this->processConfiguration($configuration, $configs);
29
30
        $loader = new XmlFileLoader(
31
            $container,
32
            new FileLocator(__DIR__ . '/../Resources/config')
33
        );
34
        $loader->load('services.xml');
35
36
        $definition = $container->getDefinition('bugloos_query_sorting.query_sorting');
37
        $definition->setArgument(3, $config['default_cache_time']);
38
        $definition->setArgument(4, $config['separator']);
39
    }
40
}
41