KnpDictionaryExtension::load()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 15
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 27
ccs 0
cts 13
cp 0
crap 2
rs 9.7666
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Knp\DictionaryBundle\DependencyInjection;
6
7
use Knp\DictionaryBundle\DependencyInjection\Compiler\DictionaryFactoryBuildingPass;
8
use Knp\DictionaryBundle\DependencyInjection\Compiler\DictionaryRegistrationPass;
9
use Knp\DictionaryBundle\Dictionary;
10
use Symfony\Component\Config\FileLocator;
11
use Symfony\Component\DependencyInjection\ContainerBuilder;
12
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
13
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
14
15
final class KnpDictionaryExtension extends Extension
16
{
17
    /**
18
     * @param array<mixed, mixed> $config
19
     */
20
    public function load(array $config, ContainerBuilder $containerBuilder): void
21
    {
22
        $configuration = new Configuration();
23
24
        $containerBuilder
25
            ->setParameter(
26
                'knp_dictionary.configuration',
27
                $this->processConfiguration($configuration, $config)
28
            )
29
        ;
30
31
        $containerBuilder
32
            ->registerForAutoconfiguration(Dictionary::class)
33
            ->addTag(DictionaryRegistrationPass::TAG_DICTIONARY)
34
        ;
35
36
        $containerBuilder
37
            ->registerForAutoconfiguration(Dictionary\Factory::class)
38
            ->addTag(DictionaryFactoryBuildingPass::TAG_FACTORY)
39
        ;
40
41
        $yamlFileLoader = new YamlFileLoader(
42
            $containerBuilder,
43
            new FileLocator(__DIR__.'/../Resources/config')
44
        );
45
46
        $yamlFileLoader->load('services.yaml');
47
    }
48
}
49