Completed
Push — master ( a37b1d...a8a96a )
by Tobias
22:51
created

AppKernel::serialize()   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 php-cache\cache-bundle package.
5
 *
6
 * (c) 2015-2015 Aaron Scherer <[email protected]>, Tobias Nyholm <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Cache\CacheBundle\Tests\Functional\app;
13
14
use Symfony\Component\Config\Loader\LoaderInterface;
15
use Symfony\Component\Filesystem\Filesystem;
16
use Symfony\Component\HttpKernel\Kernel;
17
18
class AppKernel extends Kernel
19
{
20
    private $config;
21
22
    public function __construct($config)
23
    {
24
        parent::__construct('test', true);
25
26
        $fs = new Filesystem();
27
28
        if (!$fs->isAbsolutePath($config)) {
29
            $config = __DIR__.'/config/'.$config;
30
        }
31
32
        if (!file_exists($config)) {
33
            throw new \RuntimeException(sprintf('The config file "%s" does not exist', $config));
34
        }
35
36
        $this->config = $config;
37
    }
38
39
    public function registerBundles()
40
    {
41
        return [
42
            new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
43
            new \Cache\CacheBundle\CacheBundle(),
44
        ];
45
    }
46
47
    public function registerContainerConfiguration(LoaderInterface $loader)
48
    {
49
        $loader->load($this->config);
50
    }
51
52
    public function getCacheDir()
53
    {
54
        return sys_get_temp_dir().'/TestBundle';
55
    }
56
57
    public function serialize()
58
    {
59
        return $this->config;
60
    }
61
62
    public function unserialize($config)
63
    {
64
        $this->__construct($config);
65
    }
66
}
67