1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Spiral Framework. |
4
|
|
|
* |
5
|
|
|
* @license MIT |
6
|
|
|
* @author Anton Titov (Wolfy-J) |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Spiral\Framework; |
10
|
|
|
|
11
|
|
|
use Spiral\Boot\AbstractKernel; |
12
|
|
|
use Spiral\Boot\Bootloaders\CoreBootloader; |
13
|
|
|
use Spiral\Boot\Exceptions\FrameworkException; |
14
|
|
|
use Spiral\Debug\Bootloaders\DebugBootloader; |
15
|
|
|
use Spiral\Encrypter\Bootloaders\EncrypterBootloader; |
16
|
|
|
use Spiral\Tokenizer\Bootloaders\TokenizerBootloader; |
17
|
|
|
|
18
|
|
|
abstract class Kernel extends AbstractKernel |
19
|
|
|
{ |
20
|
|
|
const SYSTEM = [ |
21
|
|
|
CoreBootloader::class, |
22
|
|
|
DebugBootloader::class, |
23
|
|
|
EncrypterBootloader::class, |
24
|
|
|
TokenizerBootloader::class, |
25
|
|
|
]; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Normalizes directory list and adds all required alises. |
29
|
|
|
* |
30
|
|
|
* @param array $directories |
31
|
|
|
* @return array |
32
|
|
|
*/ |
33
|
|
|
protected function mapDirectories(array $directories): array |
34
|
|
|
{ |
35
|
|
|
if (!isset($directories['root'])) { |
36
|
|
|
throw new FrameworkException("Missing required directory `root`."); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
if (!isset($directories['app'])) { |
40
|
|
|
$directories['app'] = $directories['root'] . '/app/'; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
return array_merge([ |
44
|
|
|
// public root |
45
|
|
|
'public' => $directories['root'] . '/public/', |
46
|
|
|
|
47
|
|
|
// vendor libraries |
48
|
|
|
'vendor' => $directories['root'] . '/vendor/', |
49
|
|
|
|
50
|
|
|
// data directories |
51
|
|
|
'runtime' => $directories['root'] . '/runtime/', |
52
|
|
|
'cache' => $directories['root'] . '/runtime/cache/', |
53
|
|
|
|
54
|
|
|
// application directories |
55
|
|
|
'config' => $directories['app'] . '/config/', |
56
|
|
|
'resources' => $directories['app'] . '/resources/', |
57
|
|
|
], $directories); |
58
|
|
|
} |
59
|
|
|
} |