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
|
|
|
|