Completed
Push — 5.3 ( 8fa806...95d990 )
by Jeroen
20:52 queued 14:24
created

KunstmaanSeoExtension::prepend()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
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
    public function load(array $configs, ContainerBuilder $container)
24
    {
25
        $configuration = new Configuration();
26
        $config = $this->processConfiguration($configuration, $configs);
27
28
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
29
        $loader->load('services.yml');
30
        $loader->load('parameters.yml');
31
32
        if ($config['request_cache']) {
33
            $serviceDef = $container->findDefinition('kunstmaan_seo.twig.extension');
34
35
            $serviceDef->addMethodCall('setRequestCache', [new Reference($config['request_cache'])]);
36
        }
37
    }
38
39
    public function prepend(ContainerBuilder $container)
40
    {
41
        $liipConfig = Yaml::parse(file_get_contents(__DIR__ . '/../Resources/config/imagine_filters.yml'));
42
        $container->prependExtensionConfig('liip_imagine', $liipConfig['liip_imagine']);
43
44
        $configs = $container->getExtensionConfig($this->getAlias());
45
        $this->processConfiguration(new Configuration(), $configs);
46
    }
47
}
48