MyPoseoExtension::load()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

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