AppKernel::getCacheDir()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
namespace Smartbox\CoreBundle\Tests;
4
5
use Symfony\Component\Filesystem\Filesystem;
6
use Symfony\Component\HttpKernel\Kernel;
7
use Symfony\Component\Config\Loader\LoaderInterface;
8
use Smartbox\CoreBundle\DependencyInjection\CacheDriversCompilerPass;
9
10
class AppKernel extends Kernel
11
{
12
    private $cacheDir;
13
14
    public function registerBundles()
15
    {
16
        $bundles = [
17
            new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
18
            new \Symfony\Bundle\MonologBundle\MonologBundle(),
19
            new \JMS\SerializerBundle\JMSSerializerBundle(),
20
            new \Smartbox\CoreBundle\SmartboxCoreBundle(),
21
        ];
22
23
        switch ($this->getEnvironment()) {
24
            case CacheDriversCompilerPass::PREDEFINED_CACHE_DRIVER_PREDIS:
25
                $bundles[] = new \Snc\RedisBundle\SncRedisBundle();
26
                break;
27
        }
28
29
        return $bundles;
30
    }
31
32
    public function registerContainerConfiguration(LoaderInterface $loader)
33
    {
34
        $config = 'config';
35
        if ('test' !== $this->getEnvironment()) {
36
            $config = 'config_'.$this->getEnvironment();
37
        }
38
39
        $loader->load($this->getRootDir().'/config/'.$config.'.yml');
0 ignored issues
show
Deprecated Code introduced by
The method Symfony\Component\HttpKernel\Kernel::getRootDir() has been deprecated with message: since Symfony 4.2, use getProjectDir() instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
40
    }
41
42
    public function getCacheDir()
43
    {
44
        if (!$this->cacheDir) {
45
            $this->cacheDir = sys_get_temp_dir().'/sbx_core_bundle_tests';
46
        }
47
48
        return $this->cacheDir;
49
    }
50
51
    public function shutdown()
52
    {
53
        parent::shutdown();
54
55
        $fs = new Filesystem();
56
        $fs->remove($this->getCacheDir());
57
    }
58
}
59