|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Config; |
|
6
|
|
|
|
|
7
|
|
|
use DI\ContainerBuilder; |
|
8
|
|
|
use Psr\Container\ContainerInterface; |
|
9
|
|
|
use Stu\Module\Config\StuConfigInterface; |
|
10
|
|
|
use Stu\Module\Twig\TwigHelper; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Inits the application by calling the provided callable and injecting the DIC |
|
14
|
|
|
*/ |
|
15
|
|
|
final class Init |
|
16
|
|
|
{ |
|
17
|
|
|
private static ?ContainerInterface $CONTAINER = null; |
|
18
|
|
|
|
|
19
|
4 |
|
public static function getContainer(): ContainerInterface |
|
20
|
|
|
{ |
|
21
|
4 |
|
if (static::$CONTAINER === null) { |
|
|
|
|
|
|
22
|
|
|
// ordered alphabetically |
|
23
|
4 |
|
$builder = new ContainerBuilder(); |
|
24
|
4 |
|
$builder->addDefinitions(__DIR__ . '/services.php'); |
|
25
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Component/Admin/services.php'); |
|
26
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Component/Alliance/services.php'); |
|
27
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Component/Anomaly/services.php'); |
|
28
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Component/Building/services.php'); |
|
29
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Component/Cli/services.php'); |
|
30
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Component/Colony/services.php'); |
|
31
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Component/Communication/services.php'); |
|
32
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Component/Crew/services.php'); |
|
33
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Component/Game/services.php'); |
|
34
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Component/GrapViz/services.php'); |
|
35
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Component/History/services.php'); |
|
36
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Component/Image/services.php'); |
|
37
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Component/Index/services.php'); |
|
38
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Component/Logging/services.php'); |
|
39
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Component/Map/services.php'); |
|
40
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Component/Player/services.php'); |
|
41
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Component/Ship/services.php'); |
|
42
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Component/Station/services.php'); |
|
43
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Component/StarSystem/services.php'); |
|
44
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Lib/services.php'); |
|
45
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Module/Admin/services.php'); |
|
46
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Module/Alliance/services.php'); |
|
47
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Module/Award/services.php'); |
|
48
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Module/Building/services.php'); |
|
49
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Module/Colony/services.php'); |
|
50
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Module/Commodity/services.php'); |
|
51
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Module/Communication/services.php'); |
|
52
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Module/Control/services.php'); |
|
53
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Module/Crew/services.php'); |
|
54
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Module/Database/services.php'); |
|
55
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Module/Game/services.php'); |
|
56
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Module/History/services.php'); |
|
57
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Module/Index/services.php'); |
|
58
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Module/Logging/services.php'); |
|
59
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Module/Maindesk/services.php'); |
|
60
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Module/Maintenance/services.php'); |
|
61
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Module/Message/services.php'); |
|
62
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Module/Notes/services.php'); |
|
63
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Module/NPC/services.php'); |
|
64
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Module/PlayerProfile/services.php'); |
|
65
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Module/PlayerSetting/services.php'); |
|
66
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Module/Prestige/services.php'); |
|
67
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Module/Research/services.php'); |
|
68
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Module/Ship/services.php'); |
|
69
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Module/Starmap/services.php'); |
|
70
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Module/Station/services.php'); |
|
71
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Module/Template/services.php'); |
|
72
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Module/Tick/services.php'); |
|
73
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Module/Trade/services.php'); |
|
74
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Module/Twig/services.php'); |
|
75
|
4 |
|
$builder->addDefinitions(__DIR__ . '/../Orm/Repository/services.php'); |
|
76
|
|
|
|
|
77
|
4 |
|
static::$CONTAINER = $builder->build(); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
4 |
|
return static::$CONTAINER; |
|
|
|
|
|
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @param callable(ContainerInterface): mixed $app |
|
85
|
|
|
*/ |
|
86
|
4 |
|
public static function run(callable $app, bool $registerErrorHandlers = true): void |
|
87
|
|
|
{ |
|
88
|
4 |
|
date_default_timezone_set('Europe/Berlin'); |
|
89
|
|
|
|
|
90
|
4 |
|
$container = static::getContainer(); |
|
91
|
|
|
|
|
92
|
4 |
|
$config = $container->get(StuConfigInterface::class); |
|
93
|
|
|
|
|
94
|
4 |
|
$container->get(ErrorHandler::class)->register($registerErrorHandlers); |
|
95
|
|
|
|
|
96
|
4 |
|
set_include_path(get_include_path() . PATH_SEPARATOR . $config->getGameSettings()->getWebroot()); |
|
97
|
|
|
|
|
98
|
|
|
// TWIG |
|
99
|
4 |
|
$twigHelper = $container->get(TwigHelper::class); |
|
100
|
4 |
|
$twigHelper->registerFiltersAndFunctions(); |
|
101
|
4 |
|
$twigHelper->registerGlobalVariables(); |
|
102
|
|
|
|
|
103
|
4 |
|
$app($container); |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
|