Passed
Pull Request — master (#175)
by Albin
01:49
created

TestKernel::process()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 3
eloc 5
nc 4
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 build(ContainerBuilder $container)
44
    {
45
        $container->addCompilerPass($this);
46
    }
47
48
    public function process(ContainerBuilder $container)
49
    {
50
        if ($container->has('knp_snappy.pdf')) {
51
            $container->findDefinition('knp_snappy.pdf')->setPublic(true);
52
        }
53
        if ($container->has('knp_snappy.image')) {
54
            $container->findDefinition('knp_snappy.image')->setPublic(true);
55
        }
56
    }
57
}
58