VesloSanityExtension::load()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 34
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 23
c 2
b 0
f 0
dl 0
loc 34
rs 9.552
cc 2
nc 2
nop 2
1
<?php
2
3
/*
4
 * This file is part of the Veslo project <https://github.com/symfony-doge/veslo>.
5
 *
6
 * (C) 2019 Pavel Petrov <[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
 * @license https://opensource.org/licenses/GPL-3.0 GPL-3.0
12
 */
13
14
declare(strict_types=1);
15
16
namespace Veslo\SanityBundle\DependencyInjection;
17
18
use Symfony\Component\Config\FileLocator;
19
use Symfony\Component\DependencyInjection\ContainerBuilder;
20
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
21
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
22
23
/**
24
 * SanityBundle dependency injection extension.
25
 */
26
class VesloSanityExtension extends Extension
27
{
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function load(array $configs, ContainerBuilder $container)
32
    {
33
        $locator = new FileLocator(__DIR__ . implode(DIRECTORY_SEPARATOR, ['', '..', 'Resources']));
34
        $loader  = new YamlFileLoader($container, $locator);
35
36
        $configFiles = [
37
            'commands.yml',
38
            'event_listeners.yml',
39
            'entity_repositories.yml',
40
            'entity_creators.yml',
41
            'workers.yml',
42
            'providers.yml',
43
            'normalizers.yml',
44
            'synchronizers.yml',
45
            'vacancy_analysers.yml',
46
        ];
47
48
        foreach ($configFiles as $configFile) {
49
            $loader->load('config' . DIRECTORY_SEPARATOR . $configFile);
50
        }
51
52
        $configuration = new Configuration();
53
        $config        = $this->processConfiguration($configuration, $configs);
54
55
        $motAnalyserOptions = [
56
            'default_locale' => $config['vacancy']['analyser']['default_locale'],
57
            'locales'        => $config['vacancy']['analyser']['locales'],
58
        ];
59
60
        $container->setParameter('veslo.sanity.vacancy.analyser.ministry_of_truth.options', $motAnalyserOptions);
61
62
        $container->setParameter(
63
            'veslo.sanity.vacancy.tag.group.provider.ministry_of_truth.options',
64
            $motAnalyserOptions
65
        );
66
    }
67
}
68