Completed
Push — master ( f9a203...1ba3b5 )
by MoshiMoshi
04:04
created

YahooJapanConfigCacheExtension   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A prepend() 0 5 1
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
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
19
20
/**
21
 * This is the class that loads and manages your bundle configuration
22
 *
23
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
24
 */
25
class YahooJapanConfigCacheExtension extends Extension implements PrependExtensionInterface
26
{
27
    /**
28
     * {@inheritdoc}
29
     */
30 7
    public function prepend(ContainerBuilder $container)
31
    {
32 7
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
33 7
        $loader->load('parameters.yml');
34 7
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39 16
    public function load(array $configs, ContainerBuilder $container)
40
    {
41 16
        $configuration = new Configuration();
42 16
        $config = $this->processConfiguration($configuration, $configs);
43
44 13
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
45 13
        $loader->load('services.yml');
46
47 13
        if (isset($config['locale']) && $this->isConfigEnabled($container, $config['locale'])) {
48 3
            $container->setParameter('yahoo_japan_config_cache.locales', $config['locale']['locales']);
49 3
            $container->setParameter('yahoo_japan_config_cache.listener_priority', $config['locale']['listener_priority']);
50 3
            $container->setParameter('yahoo_japan_config_cache.loader', $config['locale']['loader']);
51 3
        } else {
52 10
            $container->removeDefinition('yahoo_japan_config_cache.config_cache_listener');
53
        }
54 13
    }
55
}
56