CrudsTestKernel::buildContainer()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace ScayTrase\Api\Cruds\Tests\Fixtures\Common;
4
5
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
6
use Liip\FunctionalTestBundle\LiipFunctionalTestBundle;
7
use ScayTrase\Api\Cruds\CrudsBundle;
8
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
9
use Symfony\Component\Config\ConfigCache;
10
use Symfony\Component\Config\Loader\LoaderInterface;
11
use Symfony\Component\Config\Resource\FileResource;
12
use Symfony\Component\HttpKernel\Kernel;
13
14
abstract class CrudsTestKernel extends Kernel
15
{
16
    /** {@inheritdoc} */
17
    public function registerBundles()
18
    {
19
        return [
20
            new CrudsBundle(),
21
            new DoctrineBundle(),
22
            new MyBundle(),
23
            new FrameworkBundle(),
24
            new LiipFunctionalTestBundle(),
25
        ];
26
    }
27
28
    public function getLogDir()
29
    {
30
        return __DIR__ . '/../../../build/' . $this->getClassName() . '/logs';
31
    }
32
33
    /** {@inheritdoc} */
34
    public function registerContainerConfiguration(LoaderInterface $loader)
35
    {
36
        return $loader->load(__DIR__ . '/config.yml');
37
    }
38
39
    public function getCacheDir()
40
    {
41
        return __DIR__ . '/../../../build/' . $this->getClassName() . '/cache';
42
    }
43
44
    protected function initializeContainer()
45
    {
46
        $class = $this->getContainerClass();
47
        $cache = new ConfigCache($this->getCacheDir() . '/' . $class . '.php', $this->debug);
48
49
        $container = $this->buildContainer();
50
        $container->compile();
51
        $this->dumpContainer($cache, $container, $class, $this->getContainerBaseClass());
52
53
        parent::initializeContainer();
54
    }
55
56
    /** {@inheritdoc} */
57
    protected function buildContainer()
58
    {
59
        $container = parent::buildContainer();
60
        $container->addResource(new FileResource(__DIR__ . '/config.yml'));
61
        $container->addResource(new FileResource(__DIR__ . '/routing.yml'));
62
63
        return $container;
64
    }
65
66
    /**
67
     * @return array
68
     */
69
    private function getClassName()
70
    {
71
        $path = explode('\\', static::class);
72
73
        return array_pop($path);
74
    }
75
}
76