Completed
Push — master ( ae4a40...cd3ab6 )
by Tristan
13:24 queued 09:52
created

MyPoseoExtension::load()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 10
Bugs 2 Features 2
Metric Value
c 10
b 2
f 2
dl 0
loc 17
rs 9.4285
cc 2
eloc 11
nc 2
nop 2
1
<?php
2
3
/**
4
 * MyPoseo API Bundle
5
 *
6
 * @author Tristan Bessoussa <[email protected]>
7
 */
8
9
namespace Tristanbes\MyPoseoBundle\DependencyInjection;
10
11
use Symfony\Component\Config\FileLocator;
12
use Symfony\Component\DependencyInjection\Loader;
13
use Symfony\Component\DependencyInjection\ContainerBuilder;
14
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
15
16
/**
17
 * This is the class that loads and manages your bundle configuration
18
 *
19
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
20
 */
21
class MyPoseoExtension extends Extension
22
{
23
    /**
24
     * {@inheritDoc}
25
     */
26
    public function load(array $configs, ContainerBuilder $container)
27
    {
28
        $configuration = new Configuration();
29
        $config        = $this->processConfiguration($configuration, $configs);
30
        $loader        = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
31
32
        if (isset($config['api']['type']['search'])) {
33
            $loader->load('search.xml');
34
35
            $container->setParameter('my_poseo.api.search.base_url', $config['api']['type']['search']['base_url']);
36
            $container->setParameter('my_poseo.api.key', $config['api']['key']);
37
        }
38
39
        $container->setParameter('my_poseo.api.search_class', $config['api']['search_class']);
40
        $container->setParameter('my_poseo.api.cache_service_id', $config['api']['cache_service_id']);
41
        $container->setParameter('my_poseo.api.http_client', $config['api']['http_client']);
42
    }
43
}
44