|
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
|
|
|
$container->setParameter('takeit_amp_html.configuration.enabled', $config['enabled']); |
|
34
|
|
|
|
|
35
|
|
|
if (!$config['enabled']) { |
|
36
|
|
|
return; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
|
40
|
|
|
|
|
41
|
|
|
if ($config['routing']['parameter_strategy']['enabled']) { |
|
42
|
|
|
$loader->load('parameter_strategy.yml'); |
|
43
|
|
|
} else { |
|
44
|
|
|
$container->setParameter($this->getAlias().'.configuration.routing.route_strategy', $config['routing']['route_strategy']); |
|
45
|
|
|
$loader->load('route_strategy.yml'); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
$container->setAlias('takeit_amp_html.checker', $config['checker']); |
|
49
|
|
|
$container->setAlias('takeit_amp_html.converter.amp', $config['converter']); |
|
50
|
|
|
$container->setAlias('takeit_amp_html.loader.theme', $config['theme']['loader']); |
|
51
|
|
|
$loader->load('converters.yml'); |
|
52
|
|
|
$loader->load('services.yml'); |
|
53
|
|
|
|
|
54
|
|
|
unset($config['theme']['loader']); |
|
55
|
|
|
foreach ($config['theme'] as $key => $value) { |
|
56
|
|
|
$container->setParameter( |
|
57
|
|
|
$this->getAlias().'.configuration.theme.'.$key, |
|
58
|
|
|
$value |
|
59
|
|
|
); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
$container->setParameter($this->getAlias().'.configuration.model.class', $config['model']); |
|
63
|
|
|
$container->setParameter($this->getAlias().'.configuration.routing.controller', $config['routing']['controller']); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|