Completed
Push — master ( 670f0c...07e238 )
by Pavel
12:30
created

CrudsTestKernel::initializeContainer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

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