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

CrudsTestKernel   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 9

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 9
dl 0
loc 61
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A registerBundles() 0 9 1
A getCacheDir() 0 4 1
A getLogDir() 0 4 1
A registerContainerConfiguration() 0 4 1
A buildContainer() 0 8 1
A getClassName() 0 6 1
A initializeContainer() 0 11 1
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