1 | <?php |
||
31 | abstract class Kernel implements ContainerAwareInterface |
||
32 | { |
||
33 | use ContainerAwareTrait; |
||
34 | |||
35 | /** |
||
36 | * Flag indicating this Kernel has been booted |
||
37 | * |
||
38 | * @var boolean |
||
39 | */ |
||
40 | protected $booted = false; |
||
41 | |||
42 | /** |
||
43 | * Boot the Kernel |
||
44 | * |
||
45 | * @return void |
||
46 | */ |
||
47 | 12 | public function boot(): void |
|
48 | { |
||
49 | 12 | if ($this->booted) |
|
50 | { |
||
51 | return; |
||
52 | } |
||
53 | |||
54 | 12 | $this->setContainer($this->buildContainer()); |
|
55 | |||
56 | // Register deprecation logging via Monolog |
||
57 | 12 | ErrorHandler::register($this->getContainer()->get(Logger::class), [E_DEPRECATED, E_USER_DEPRECATED], false, false); |
|
58 | |||
59 | 12 | $this->booted = true; |
|
60 | 12 | } |
|
61 | |||
62 | /** |
||
63 | * Check if the Kernel is booted |
||
64 | * |
||
65 | * @return void |
||
66 | */ |
||
67 | 2 | public function isBooted(): bool |
|
71 | |||
72 | /** |
||
73 | * Run the kernel |
||
74 | * |
||
75 | * @return void |
||
76 | */ |
||
77 | 2 | public function run(): void |
|
78 | { |
||
79 | 2 | $this->boot(); |
|
80 | |||
81 | 2 | if (!$this->getContainer()->has(AbstractApplication::class)) |
|
82 | { |
||
83 | 1 | throw new \RuntimeException('The application has not been registered with the container.'); |
|
84 | } |
||
85 | |||
86 | 1 | $this->getContainer()->get(AbstractApplication::class)->execute(); |
|
87 | 1 | } |
|
88 | |||
89 | /** |
||
90 | * Build the service container |
||
91 | * |
||
92 | * @return void |
||
93 | */ |
||
94 | 12 | protected function buildContainer(): Container |
|
113 | |||
114 | /** |
||
115 | * Load the application's configuration |
||
116 | * |
||
117 | * @return Registry |
||
118 | */ |
||
119 | 12 | private function loadConfiguration(): Registry |
|
131 | } |
||
132 |