ONGRElasticsearchExtension::load()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 27

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 27
rs 9.488
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
/*
4
 * This file is part of the ONGR package.
5
 *
6
 * (c) NFQ Technologies UAB <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace ONGR\ElasticsearchBundle\DependencyInjection;
13
14
use ONGR\ElasticsearchBundle\Mapping\Converter;
15
use ONGR\ElasticsearchBundle\Mapping\DocumentParser;
16
use Symfony\Component\Config\FileLocator;
17
use Symfony\Component\DependencyInjection\ContainerBuilder;
18
use Symfony\Component\DependencyInjection\Loader;
19
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
20
21
class ONGRElasticsearchExtension extends Extension
22
{
23
    public function load(array $configs, ContainerBuilder $container)
24
    {
25
        $configuration = new Configuration();
26
        $config = $this->processConfiguration($configuration, $configs);
27
28
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
29
        $loader->load('services.yml');
30
31
        $container->setParameter(
32
            Configuration::ONGR_CACHE_CONFIG,
33
            $config['cache'] ?? $container->getParameter('kernel.debug')
34
        );
35
36
        $container->setParameter(
37
            Configuration::ONGR_PROFILER_CONFIG,
38
            $config['profiler'] ?? $container->getParameter('kernel.debug')
39
        );
40
41
        $container->setParameter(
42
            Configuration::ONGR_LOGGER_CONFIG,
43
            $config['logger'] ?? $container->getParameter('kernel.debug')
44
        );
45
46
        $container->setParameter(Configuration::ONGR_INDEXES_OVERRIDE, $config['indexes']);
47
        $container->setParameter(Configuration::ONGR_ANALYSIS_CONFIG, $config['analysis']);
48
        $container->setParameter(Configuration::ONGR_SOURCE_DIR, $config['source_directories']);
49
    }
50
}
51