/
Kernel.php
75 lines (62 loc) · 1.8 KB
/
Kernel.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/*
* This file is part of Sulu.
*
* (c) Sulu GmbH
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Sulu\Bundle\WebsiteBundle\Tests\Application;
use Sulu\Bundle\TestBundle\Kernel\SuluTestKernel;
use Symfony\Bundle\SecurityBundle\SecurityBundle;
use Symfony\Component\Config\Loader\LoaderInterface;
class Kernel extends SuluTestKernel
{
/**
* @var string
*/
private $appContext;
/**
* @param string $environment
* @param bool $debug
* @param string $suluContext
*/
public function __construct($environment, $debug, $suluContext = self::CONTEXT_ADMIN)
{
$envParts = \explode('_', $environment, 2);
$this->appContext = $envParts[1] ?? '';
parent::__construct($envParts[0], $debug, $suluContext);
}
public function registerContainerConfiguration(LoaderInterface $loader): void
{
parent::registerContainerConfiguration($loader);
$context = $this->getContext();
$loader->load(__DIR__ . '/config/config_' . $context . '.yml');
if ('' !== $this->appContext) {
$loader->load(__DIR__ . '/config/config_' . $this->appContext . '.yml');
}
}
public function registerBundles(): iterable
{
$bundles = parent::registerBundles();
if ('with_security' === $this->appContext) {
$bundles[] = new SecurityBundle();
}
return $bundles;
}
/**
* @return string
*/
public function getCacheDir()
{
return parent::getCacheDir() . \ltrim('/' . $this->appContext);
}
/**
* @return string
*/
public function getCommonCacheDir()
{
return parent::getCommonCacheDir() . \ltrim('/' . $this->appContext);
}
}