Completed
Push — master ( 57a491...f9215d )
by Rafał
8s
created

TakeitAmpHtmlExtension::load()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 26
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 2
Metric Value
c 2
b 0
f 2
dl 0
loc 26
rs 8.8571
cc 2
eloc 16
nc 2
nop 2
1
<?php
2
3
/*
4
 * This file is part of the takeit/AmpHtmlBundle package.
5
 *
6
 * (c) Rafał Muszyński <[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 Takeit\Bundle\AmpHtmlBundle\DependencyInjection;
13
14
use Symfony\Component\DependencyInjection\ContainerBuilder;
15
use Symfony\Component\Config\FileLocator;
16
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
17
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
18
19
/**
20
 * This is the class that loads and manages your bundle configuration.
21
 *
22
 * @author Rafał Muszyński <[email protected]>
23
 */
24
class TakeitAmpHtmlExtension extends Extension
25
{
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function load(array $configs, ContainerBuilder $container)
30
    {
31
        $configuration = new Configuration();
32
        $config = $this->processConfiguration($configuration, $configs);
33
34
        $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
35
36
        $container->setAlias('takeit_amp_html.converter.amp', $config['converter']);
37
        $loader->load('converters.yml');
38
        $loader->load('services.yml');
39
40
        foreach ($config['theme'] as $key => $value) {
41
            $container->setParameter(
42
                $this->getAlias().'.configuration.theme.'.$key,
43
                $value
44
            );
45
        }
46
47
        $container->setParameter(
48
            $this->getAlias().'.configuration.theme.theme_path',
49
            rtrim($config['theme']['themes_path'], '/').'/'.$config['theme']['current_theme']
50
        );
51
52
        $container->setParameter($this->getAlias().'.configuration.model.class', $config['model']);
53
        $container->setParameter($this->getAlias().'.configuration.routing', $config['routing']);
54
    }
55
}
56