Completed
Branch V3 (ec4077)
by PastisD
11:29 queued 09:28
created

PhpfastcacheExtension::load()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 2
nop 2
1
<?php
2
3
/**
4
 *
5
 * This file is part of phpFastCache.
6
 *
7
 * @license MIT License (MIT)
8
 *
9
 * For full copyright and license information, please see the docs/CREDITS.txt file.
10
 *
11
 * @author Georges.L (Geolim4)  <[email protected]>
12
 * @author PastisD https://github.com/PastisD
13
 * @author Khoa Bui (khoaofgod)  <[email protected]> http://www.phpfastcache.com
14
 *
15
 */
16
17
namespace Phpfastcache\Bundle\DependencyInjection;
18
19
use Symfony\Component\DependencyInjection\ContainerBuilder;
20
use Symfony\Component\Config\FileLocator;
21
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
22
use Symfony\Component\DependencyInjection\Loader;
23
24
/**
25
 * Class phpFastCacheExtension
26
 * @package Phpfastcache\Bundle\DependencyInjection
27
 */
28
class PhpfastcacheExtension extends Extension
29
{
30
    /**
31
     * {@inheritDoc}
32
     *
33
     * @throws \Exception
34
     * @throws \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
35
     * @throws \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException
36
     * @throws \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException
37
     */
38
    public function load(array $configs, ContainerBuilder $container)
39
    {
40
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
41
        $loader->load('services.yml');
42
43
        /**
44
         * Includes services_dev.yml only
45
         * if we are in debug mode
46
         */
47
        if(\in_array($container->getParameter('kernel.environment'), ['dev', 'test'], true)){
48
            $loader->load('services_dev.yml');
49
        }
50
51
        $configuration = new Configuration();
52
        $config = $this->processConfiguration($configuration, $configs);
53
54
        $container->setParameter('phpfastcache', $config);
55
    }
56
}
57