Completed
Push — master ( 103460...224772 )
by GBProd
02:10
created

ElasticaExtraExtension   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 6
dl 0
loc 38
ccs 23
cts 23
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A load() 0 21 2
A createIndexConfigurationRepository() 0 10 1
1
<?php
2
3
namespace GBProd\ElasticaExtraBundle\DependencyInjection;
4
5
use GBProd\ElasticaExtraBundle\Repository\IndexConfigurationRepository;
6
use Symfony\Component\Config\FileLocator;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
use Symfony\Component\DependencyInjection\Loader;
9
use Symfony\Component\DependencyInjection\Reference;
10
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
11
12
/**
13
 * Extension class for ElasticsearchExtra bundle
14
 *
15
 * @author gbprod <[email protected]>
16
 */
17
class ElasticaExtraExtension extends Extension
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22 7
    public function load(array $configs, ContainerBuilder $container)
23
    {
24 7
        $configuration = new Configuration();
25 7
        $config = $this->processConfiguration($configuration, $configs);
26
27 7
        $this->createIndexConfigurationRepository($config, $container);
28
29 7
        if (null !== $config['default_client']) {
30 1
            $container->setAlias(
31 1
                'gbprod.elastica_extra.default_client',
32 1
                $config['default_client']
33 1
            );
34 1
        }
35
36 7
        $loader = new Loader\YamlFileLoader(
37 7
            $container,
38 7
            new FileLocator(__DIR__ . '/../Resources/config')
39 7
        );
40
41 7
        $loader->load('services.yml');
42 7
    }
43
44 7
    private function createIndexConfigurationRepository(array $config, ContainerBuilder $container)
45
    {
46 1
        $container
47 7
            ->register(
48 7
                'gbprod.elastica_extra.index_configuration_repository',
49
                IndexConfigurationRepository::class
50 7
            )
51 7
            ->addArgument($config['indices'])
52
        ;
53 7
    }
54
}
55