Completed
Push — master ( e8b056...1f0b59 )
by Christian
06:37
created

Core23PiwikExtension::configureHttpClient()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
/*
4
 * This file is part of the ni-ju-san CMS.
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
class Core23PiwikExtension extends Extension
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function load(array $configs, ContainerBuilder $container)
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
        $this->configureClassesToCompile();
42
    }
43
44
    /**
45
     * @param ContainerBuilder $container
46
     * @param array            $config
47
     */
48
    private function configureHttpClient(ContainerBuilder $container, array $config)
49
    {
50
        $container->setAlias('core23.piwik.http.client', $config['http']['client']);
51
        $container->setAlias('core23.piwik.http.message_factory', $config['http']['message_factory']);
52
    }
53
54
    private function configureClassesToCompile()
55
    {
56
        $this->addClassesToCompile(array(
57
            'Core23\\PiwikBundle\\Block\\Service\\PiwikStatisticBlockService',
58
            'Core23\\PiwikBundle\\Client\\Client',
59
            'Core23\\PiwikBundle\\Connection\\ConnectionInterface',
60
            'Core23\\PiwikBundle\\Connection\\PiwikConnection',
61
            'Core23\\PiwikBundle\\Exception\\PiwikException',
62
        ));
63
    }
64
}
65