BrowscapExtension::load()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
c 0
b 0
f 0
rs 9.4285
cc 3
eloc 9
nc 4
nop 2
1
<?php
2
3
namespace Browscap\BrowscapBundle\DependencyInjection;
4
5
use Symfony\Component\DependencyInjection\ContainerBuilder;
6
use Symfony\Component\Config\FileLocator;
7
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
8
use Symfony\Component\DependencyInjection\Loader;
9
10
/**
11
 * @author Joshua Estes <[email protected]>
12
 */
13
class BrowscapExtension extends Extension
14
{
15
    /**
16
     * {@inheritDoc}
17
     */
18
    public function load(array $configs, ContainerBuilder $container)
19
    {
20
        $configuration = new Configuration();
21
        $config = $this->processConfiguration($configuration, $configs);
22
23
        $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
24
        $loader->load('services.xml');
25
26
        if( $config['cache_dir'] === null ) {
27
            $config['cache_dir'] = $container->getParameter('kernel.cache_dir');
28
        }
29
30
        foreach ($config as $k => $v) {
31
            $container->setParameter('browscap.' . $k, $v);
32
        }
33
    }
34
}
35