Completed
Branch master (2f0f48)
by MoshiMoshi
05:03
created

YahooJapanConfigCacheExtension   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 0 Features 1
Metric Value
wmc 3
c 4
b 0
f 1
lcom 0
cbo 5
dl 0
loc 22
ccs 12
cts 12
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A load() 0 16 3
1
<?php
2
3
/*
4
 * This file is part of the ConfigCacheBundle package.
5
 *
6
 * Copyright (c) 2015 Yahoo Japan Corporation
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 YahooJapan\ConfigCacheBundle\DependencyInjection;
13
14
use Symfony\Component\DependencyInjection\ContainerBuilder;
15
use Symfony\Component\Config\FileLocator;
16
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
17
use Symfony\Component\DependencyInjection\Loader;
18
19
/**
20
 * This is the class that loads and manages your bundle configuration
21
 *
22
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
23
 */
24
class YahooJapanConfigCacheExtension extends Extension
25
{
26
    /**
27
     * {@inheritdoc}
28
     */
29 18
    public function load(array $configs, ContainerBuilder $container)
30
    {
31 18
        $configuration = new Configuration();
32 18
        $config = $this->processConfiguration($configuration, $configs);
33
34 15
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
35 15
        $loader->load('services.yml');
36
37 15
        if (isset($config['locale']) && $this->isConfigEnabled($container, $config['locale'])) {
38 3
            $container->setParameter('yahoo_japan_config_cache.locales', $config['locale']['locales']);
39 3
            $container->setParameter('yahoo_japan_config_cache.listener_priority', $config['locale']['listener_priority']);
40 3
            $container->setParameter('yahoo_japan_config_cache.loader', $config['locale']['loader']);
41 3
        } else {
42 12
            $container->removeDefinition('yahoo_japan_config_cache.config_cache_listener');
43
        }
44 15
    }
45
}
46