-
Notifications
You must be signed in to change notification settings - Fork 4
/
Thelia
116 lines (91 loc) · 3.06 KB
/
Thelia
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
/*
* This file is part of the Thelia package.
* http://www.thelia.net
*
* (c) OpenStudio <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Dotenv\Dotenv;
use Symfony\Component\ErrorHandler\Debug;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpKernel\Kernel;
use Thelia\Core\Application;
use Thelia\Core\Thelia;
if (!in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
echo 'Warning: The console should be invoked via the CLI version of PHP, not the '.\PHP_SAPI.' SAPI'.\PHP_EOL;
}
set_time_limit(0);
if (!isset($bootstrapFile)) {
$bootstrapFile = dirname(__DIR__).'/vendor/autoload.php';
}
require $bootstrapFile;
if (!class_exists(Application::class) || !class_exists(Dotenv::class)) {
throw new LogicException('You need to add "symfony/framework-bundle" and "symfony/dotenv" as Composer dependencies.');
}
$input = new ArgvInput();
if (null !== $askedEnv = $input->getParameterOption(['--env', '-e'], null, true)) {
putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $askedEnv);
}
(new Dotenv())->bootEnv(THELIA_ROOT.'.env', 'dev', []);
$env = $_ENV['APP_ENV'];
if ($input->hasParameterOption('--no-debug', true)) {
putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
}
if ($_SERVER['APP_DEBUG']) {
umask(0000);
if (class_exists(Debug::class)) {
Debug::enable();
}
}
// for Thelia not installed
function getTheliaDatabaseConfigFile($env = 'prod')
{
$fs = new Filesystem();
$databaseConfigFile = THELIA_CONF_DIR.'database_'.$env.'.yml';
if (!$fs->exists($databaseConfigFile)) {
$databaseConfigFile = THELIA_CONF_DIR.'database.yml';
}
return $databaseConfigFile;
}
if (!Thelia::isInstalled()) {
$kernel = new class($env = 'prod', true) extends Kernel {
use MicroKernelTrait;
public function getCacheDir(): string
{
if (defined('THELIA_ROOT')) {
return THELIA_CACHE_DIR.$this->environment;
}
return parent::getCacheDir();
}
public function getLogDir(): string
{
if (defined('THELIA_ROOT')) {
return THELIA_LOG_DIR;
} else {
return parent::getLogDir();
}
}
public function registerBundles(): array
{
return [
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
];
}
public function registerContainerConfiguration(LoaderInterface $loader): void
{
}
};
$application = new Application($kernel);
$application->run($input);
exit;
}
// end for Thelia not installed
$thelia = new App\Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$application = new Application($thelia);
$application->run($input);