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

YahooJapanConfigCacheExtension::load()   B

Complexity

Conditions 5
Paths 8

Size

Total Lines 24
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 19
CRAP Score 5

Importance

Changes 5
Bugs 0 Features 2
Metric Value
c 5
b 0
f 2
dl 0
loc 24
ccs 19
cts 19
cp 1
rs 8.5125
cc 5
eloc 16
nc 8
nop 2
crap 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