Passed
Push — master ( 1d3a89...3690f8 )
by Albin
01:05
created

TestKernel::prepareContainer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Knp\Bundle\SnappyBundle\Tests;
4
5
use Symfony\Component\Config\Loader\LoaderInterface;
6
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
use Symfony\Component\HttpKernel\Kernel;
9
10
class TestKernel extends Kernel implements CompilerPassInterface
11
{
12
    private $configurationFilename;
13
14
    /**
15
     * Defines the configuration filename.
16
     *
17
     * @param string $filename
18
     */
19
    public function setConfigurationFilename($filename)
20
    {
21
        $this->configurationFilename = $filename;
22
    }
23
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function registerBundles()
28
    {
29
        return [
30
            new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
31
            new \Knp\Bundle\SnappyBundle\KnpSnappyBundle(),
32
        ];
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function registerContainerConfiguration(LoaderInterface $loader)
39
    {
40
        $loader->load($this->configurationFilename);
41
    }
42
43
    protected function prepareContainer(ContainerBuilder $container)
44
    {
45
        parent::prepareContainer($container);
46
47
        $container->addCompilerPass($this);
48
    }
49
50
    public function process(ContainerBuilder $container)
51
    {
52
        if ($container->has('knp_snappy.pdf')) {
53
            $container->findDefinition('knp_snappy.pdf')->setPublic(true);
54
        }
55
        if ($container->has('knp_snappy.image')) {
56
            $container->findDefinition('knp_snappy.image')->setPublic(true);
57
        }
58
    }
59
}
60