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

YahooJapanConfigCacheExtension::prepend()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 1
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