|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
use Shopware\Core\HttpKernel; |
|
4
|
|
|
use Shopware\Core\Installer\InstallerKernel; |
|
5
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
6
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
7
|
|
|
use Symfony\Component\HttpKernel\HttpKernelInterface; |
|
8
|
|
|
use Symfony\Component\HttpKernel\TerminableInterface; |
|
9
|
|
|
|
|
10
|
|
|
$_SERVER['SCRIPT_FILENAME'] = __FILE__; |
|
11
|
|
|
|
|
12
|
|
|
require_once __DIR__ . '/../vendor/autoload_runtime.php'; |
|
13
|
|
|
|
|
14
|
|
|
if (!file_exists(__DIR__ . '/../.env')) { |
|
15
|
|
|
$_SERVER['APP_RUNTIME_OPTIONS']['disable_dotenv'] = true; |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
return function (array $context) { |
|
19
|
|
|
$classLoader = require __DIR__ . '/../vendor/autoload.php'; |
|
20
|
|
|
|
|
21
|
|
|
if (!file_exists(dirname(__DIR__) . '/install.lock')) { |
|
22
|
|
|
$baseURL = str_replace(basename(__FILE__), '', $_SERVER['SCRIPT_NAME']); |
|
23
|
|
|
$baseURL = rtrim($baseURL, '/'); |
|
24
|
|
|
|
|
25
|
|
|
if (!str_contains($_SERVER['REQUEST_URI'], '/installer')) { |
|
26
|
|
|
header('Location: ' . $baseURL . '/installer'); |
|
27
|
|
|
exit; |
|
28
|
|
|
} |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
$appEnv = $context['APP_ENV'] ?? 'dev'; |
|
32
|
|
|
$debug = (bool) ($context['APP_DEBUG'] ?? ($appEnv !== 'prod')); |
|
33
|
|
|
|
|
34
|
|
|
$trustedProxies = $context['TRUSTED_PROXIES'] ?? false; |
|
35
|
|
|
if ($trustedProxies) { |
|
36
|
|
|
Request::setTrustedProxies( |
|
37
|
|
|
explode(',', $trustedProxies), |
|
38
|
|
|
Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO |
|
39
|
|
|
); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
$trustedHosts = $context['TRUSTED_HOSTS'] ?? false; |
|
43
|
|
|
if ($trustedHosts) { |
|
44
|
|
|
Request::setTrustedHosts(explode(',', $trustedHosts)); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
if (!file_exists(dirname(__DIR__) . '/install.lock')) { |
|
48
|
|
|
return new InstallerKernel($appEnv, $debug); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
$shopwareHttpKernel = new HttpKernel($appEnv, $debug, $classLoader); |
|
52
|
|
|
|
|
53
|
|
|
return new class($shopwareHttpKernel) implements HttpKernelInterface, TerminableInterface { |
|
54
|
|
|
private HttpKernel $httpKernel; |
|
55
|
|
|
|
|
56
|
|
|
public function __construct(HttpKernel $httpKernel) |
|
57
|
|
|
{ |
|
58
|
|
|
$this->httpKernel = $httpKernel; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function handle(Request $request, int $type = self::MAIN_REQUEST, bool $catch = true): Response |
|
62
|
|
|
{ |
|
63
|
|
|
return $this->httpKernel->handle($request, $type, $catch)->getResponse(); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function terminate(Request $request, Response $response): void |
|
67
|
|
|
{ |
|
68
|
|
|
$this->httpKernel->terminate($request, $response); |
|
69
|
|
|
} |
|
70
|
|
|
}; |
|
71
|
|
|
}; |
|
72
|
|
|
|