Completed
Pull Request — master (#3)
by Tristan
14:00 queued 09:37
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\DependencyInjection\Reference;
15
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
16
17
/**
18
 * This is the class that loads and manages your bundle configuration
19
 *
20
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
21
 */
22
class MyPoseoExtension extends Extension
23
{
24
    /**
25
     * {@inheritDoc}
26
     */
27
    public function load(array $configs, ContainerBuilder $container)
28
    {
29
        $configuration = new Configuration();
30
        $config        = $this->processConfiguration($configuration, $configs);
31
        $loader        = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
32
33
        if (isset($config['api']['type']['search'])) {
34
            $loader->load('search.xml');
35
36
            $container->setParameter('my_poseo.api.search.base_url', $config['api']['type']['search']['base_url']);
37
            $container->setParameter('my_poseo.api.key', $config['api']['key']);
38
        }
39
40
        $container->setParameter('my_poseo.api.search_class', $config['api']['search_class']);
41
        $container->setParameter('my_poseo.api.cache_service_id', $config['api']['cache_service_id']);
42
        $container->setParameter('my_poseo.api.http_client', $config['api']['http_client']);
43
    }
44
}
45