-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathAppKernel.php
81 lines (71 loc) · 1.98 KB
/
AppKernel.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
76
77
78
79
80
81
<?php
use Shopware\Kernel;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
class AppKernel extends Kernel
{
/**
* @param string $environment
* @param bool $debug
*
* @throws \Exception
*/
public function __construct($environment, $debug)
{
$this->loadRelease();
parent::__construct($environment, $debug);
}
protected function initializeShopware()
{
$this->shopware = new Application($this->container);
$this->container->setApplication($this->shopware);
}
/**
* @return string
*/
protected function getConfigPath()
{
return __DIR__ . '/config/config.php';
}
/**
* @return string
*/
public function getCacheDir()
{
return dirname(__DIR__) . '/var/cache/' . $this->getEnvironment() . '_' . $this->release['revision'];
}
/**
* Gets the log directory.
*
* @return string The log directory
*/
public function getLogDir()
{
return dirname(__DIR__) . '/var/log';
}
/**
* @param ContainerBuilder $container
*
* @throws Exception
*/
protected function prepareContainer(ContainerBuilder $container)
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__));
$loader->load('services.xml');
parent::prepareContainer($container);
}
private function loadRelease(): void
{
try {
$release = ShopwareVersion::parseVersion();
} catch (\OutOfBoundsException $ex) {
$release = [
'version' => $_SERVER['SHOPWARE_VERSION'] ?? '___VERSION___',
'version_text' => $_SERVER['SHOPWARE_VERSION_TEXT'] ?? '___VERSION_TEXT___',
'revision' => $_SERVER['SHOPWARE_REVISION'] ?? '___REVISION___',
];
}
$this->release = $release;
}
}