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

I18nRoutingExtension::getAlias()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
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
}