Completed
Push — master ( 68214f...bca5bf )
by Frank
03:13
created

I18nRoutingExtension   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 6
dl 0
loc 32
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getAlias() 0 4 1
A load() 0 12 1
A configureAnnotationLoader() 0 6 2
1
<?php
2
3
namespace FrankDeJonge\SymfonyI18nRouting\DependencyInjection;
4
5
use Symfony\Component\Config\FileLocator;
6
use Symfony\Component\Config\Loader\LoaderInterface;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
9
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
10
11
class I18nRoutingExtension extends Extension
12
{
13 6
    public function getAlias()
14
    {
15 6
        return 'frankdejonge_i18n_routing';
16
    }
17
18
    /**
19
     * Loads a specific configuration.
20
     *
21
     * @throws \InvalidArgumentException When provided tag is not defined in this extension
22
     */
23 6
    public function load(array $configs, ContainerBuilder $container)
24
    {
25 6
        $loader = new PhpFileLoader(
26 6
            $container,
27 6
            new FileLocator(__DIR__ . '/../Resources/config/')
28
        );
29
30 6
        $loader->load('services.php');
31 6
        $config = $this->processConfiguration(new Configuration(), $configs);
32 6
        $container->setParameter('frankdejonge_i18n_routing.default_locale', $config['default_locale']);
33 6
        $this->configureAnnotationLoader($config, $loader);
34 6
    }
35
36 6
    private function configureAnnotationLoader(array $config, LoaderInterface $loader)
37
    {
38 6
        if ($config['use_annotations'] ?? false) {
39 2
            $loader->load('annotations.php');
40
        }
41
    }
42
}