Passed
Push — master ( b74a1f...762e12 )
by MoshiMoshi
03:10
created

YahooJapanConfigCacheExtension   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 6
Bugs 0 Features 2
Metric Value
wmc 5
c 6
b 0
f 2
lcom 0
cbo 5
dl 0
loc 30
ccs 19
cts 19
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B load() 0 24 5
1
<?php
2
3
/*
4
 * This file is part of the ConfigCacheBundle package.
5
 *
6
 * Copyright (c) 2015-2016 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 25
    public function load(array $configs, ContainerBuilder $container)
30
    {
31 25
        $configuration = new Configuration();
32 25
        $config = $this->processConfiguration($configuration, $configs);
33
34 22
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
35 22
        $loader->load('services.yml');
36
37 22
        if (!$config['cache_warmup']) {
38 1
            $container->removeDefinition('yahoo_japan_config_cache.cache_warmer');
39 1
        }
40 22
        if (!$config['cache_restore']) {
41 11
            $container->removeDefinition('yahoo_japan_config_cache.cache_restorer');
42 11
            $container->removeDefinition('yahoo_japan_config_cache.cache_cleanup');
43 11
        }
44
45 22
        if (isset($config['locale']) && $this->isConfigEnabled($container, $config['locale'])) {
46 3
            $container->setParameter('yahoo_japan_config_cache.locales', $config['locale']['locales']);
47 3
            $container->setParameter('yahoo_japan_config_cache.listener_priority', $config['locale']['listener_priority']);
48 3
            $container->setParameter('yahoo_japan_config_cache.loader', $config['locale']['loader']);
49 3
        } else {
50 19
            $container->removeDefinition('yahoo_japan_config_cache.locale.listener');
51
        }
52 22
    }
53
}
54