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

TestKernel   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 7
lcom 1
cbo 6
dl 0
loc 48
rs 10
c 1
b 1
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setConfigurationFilename() 0 4 1
A registerBundles() 0 7 1
A registerContainerConfiguration() 0 4 1
A build() 0 4 1
A process() 0 9 3
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