Completed
Pull Request — master (#366)
by Beñat
04:50
created

AppKernel::getCacheDir()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Kreta package.
5
 *
6
 * (c) Beñat Espiña <[email protected]>
7
 * (c) Gorka Laucirica <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
declare(strict_types=1);
14
15
namespace Kreta\Notifier\Infrastructure\Symfony\Framework;
16
17
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
18
use Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle;
19
use Http\HttplugBundle\HttplugBundle;
20
use Nelmio\CorsBundle\NelmioCorsBundle;
21
use OldSound\RabbitMqBundle\OldSoundRabbitMqBundle;
22
use PSS\SymfonyMockerContainer\DependencyInjection\MockerContainer;
23
use SimpleBus\SymfonyBridge\SimpleBusCommandBusBundle;
24
use SimpleBus\SymfonyBridge\SimpleBusEventBusBundle;
25
use Snc\RedisBundle\SncRedisBundle;
26
use Symfony\Bundle\DebugBundle\DebugBundle;
27
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
28
use Symfony\Bundle\MonologBundle\MonologBundle;
29
use Symfony\Bundle\SecurityBundle\SecurityBundle;
30
use Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle;
31
use Symfony\Bundle\TwigBundle\TwigBundle;
32
use Symfony\Bundle\WebProfilerBundle\WebProfilerBundle;
33
use Symfony\Bundle\WebServerBundle\WebServerBundle;
34
use Symfony\Component\Config\Loader\LoaderInterface;
35
use Symfony\Component\HttpKernel\Kernel;
36
37
class AppKernel extends Kernel
38
{
39
    public function registerBundles() : array
40
    {
41
        $bundles = [
42
            new DoctrineBundle(),
43
            new DoctrineMigrationsBundle(),
44
            new FrameworkBundle(),
45
            new HttplugBundle(),
46
            new MonologBundle(),
47
            new NelmioCorsBundle(),
48
            new OldSoundRabbitMqBundle(),
49
            new SecurityBundle(),
50
            new SimpleBusCommandBusBundle(),
51
            new SimpleBusEventBusBundle(),
52
            new SncRedisBundle(),
53
            new SwiftmailerBundle(),
54
            new TwigBundle(),
55
        ];
56
57
        if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
58
            $bundles[] = new DebugBundle();
59
            $bundles[] = new WebProfilerBundle();
60
61
            if ('dev' === $this->getEnvironment()) {
62
                $bundles[] = new WebServerBundle();
63
            }
64
        }
65
66
        return $bundles;
67
    }
68
69
    public function getRootDir() : string
70
    {
71
        return __DIR__;
72
    }
73
74
    public function getCacheDir() : string
75
    {
76
        return dirname(__DIR__) . '/../../../../../var/cache/' . $this->getEnvironment();
77
    }
78
79
    public function getLogDir() : string
80
    {
81
        return dirname(__DIR__) . '/../../../../../var/logs';
82
    }
83
84
    public function registerContainerConfiguration(LoaderInterface $loader) : void
85
    {
86
        $loader->load($this->getRootDir() . '/config/config_' . $this->getEnvironment() . '.yml');
87
    }
88
89
    protected function getContainerBaseClass() : string
90
    {
91
        if ('test' === $this->environment) {
92
            return MockerContainer::class;
93
        }
94
95
        return parent::getContainerBaseClass();
96
    }
97
}
98