Core23PiwikExtension::load()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 9
nc 2
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * (c) Christian Gripp <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Core23\PiwikBundle\DependencyInjection;
13
14
use Symfony\Component\Config\FileLocator;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Loader;
17
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
18
19
final class Core23PiwikExtension extends Extension
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function load(array $configs, ContainerBuilder $container): void
25
    {
26
        $configuration = new Configuration();
27
        $config        = $this->processConfiguration($configuration, $configs);
28
29
        $bundles = $container->getParameter('kernel.bundles');
30
31
        $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
32
33
        $loader->load('services.xml');
34
35
        if (isset($bundles['SonataBlockBundle'])) {
36
            $loader->load('block.xml');
37
        }
38
39
        $this->configureHttpClient($container, $config);
40
    }
41
42
    /**
43
     * @param ContainerBuilder $container
44
     * @param array            $config
45
     */
46
    private function configureHttpClient(ContainerBuilder $container, array $config): void
47
    {
48
        $container->setAlias('core23_piwik.http.client', $config['http']['client']);
49
        $container->setAlias('core23_piwik.http.message_factory', $config['http']['message_factory']);
50
    }
51
}
52