1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kunstmaan\SeoBundle\DependencyInjection; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Config\FileLocator; |
6
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
7
|
|
|
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; |
8
|
|
|
use Symfony\Component\DependencyInjection\Loader; |
9
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
10
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
11
|
|
|
use Symfony\Component\Yaml\Yaml; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* This is the class that loads and manages your bundle configuration |
15
|
|
|
* |
16
|
|
|
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} |
17
|
|
|
*/ |
18
|
|
|
class KunstmaanSeoExtension extends Extension implements PrependExtensionInterface |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* {@inheritdoc} |
22
|
|
|
*/ |
23
|
2 |
|
public function load(array $configs, ContainerBuilder $container) |
24
|
|
|
{ |
25
|
2 |
|
$configuration = new Configuration(); |
26
|
2 |
|
$config = $this->processConfiguration($configuration, $configs); |
27
|
|
|
|
28
|
2 |
|
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
29
|
2 |
|
$loader->load('services.yml'); |
30
|
2 |
|
$loader->load('parameters.yml'); |
31
|
|
|
|
32
|
2 |
|
if ($config['request_cache']) { |
33
|
1 |
|
$serviceDef = $container->findDefinition('kunstmaan_seo.twig.extension'); |
34
|
|
|
|
35
|
1 |
|
$serviceDef->addMethodCall('setRequestCache', [new Reference($config['request_cache'])]); |
36
|
|
|
} |
37
|
2 |
|
} |
38
|
|
|
|
39
|
2 |
|
public function prepend(ContainerBuilder $container) |
40
|
|
|
{ |
41
|
2 |
|
$liipConfig = Yaml::parse(file_get_contents(__DIR__ . '/../Resources/config/imagine_filters.yml')); |
42
|
2 |
|
$container->prependExtensionConfig('liip_imagine', $liipConfig['liip_imagine']); |
43
|
|
|
|
44
|
2 |
|
$configs = $container->getExtensionConfig($this->getAlias()); |
45
|
2 |
|
$this->processConfiguration(new Configuration(), $configs); |
46
|
2 |
|
} |
47
|
|
|
} |
48
|
|
|
|