1 | <?php declare(strict_types = 1); |
||
28 | abstract class AbstractKernel implements Kernel |
||
29 | { |
||
30 | const VERSION = '0.1.0'; |
||
31 | |||
32 | /** |
||
33 | * Service container class name. |
||
34 | * |
||
35 | * @var string |
||
36 | */ |
||
37 | protected $containerClass = \Venta\Container\MutableContainer::class; |
||
38 | |||
39 | /** |
||
40 | * @var ServiceProvider[] |
||
41 | */ |
||
42 | private $providers = []; |
||
43 | |||
44 | /** |
||
45 | * @inheritDoc |
||
46 | */ |
||
47 | public function boot(): Container |
||
76 | |||
77 | /** |
||
78 | * @inheritDoc |
||
79 | */ |
||
80 | public function environment(): string |
||
84 | |||
85 | /** |
||
86 | * @inheritDoc |
||
87 | */ |
||
88 | public function isCli(): bool |
||
92 | |||
93 | /** |
||
94 | * @return string |
||
95 | */ |
||
96 | abstract public function rootPath(): string; |
||
97 | |||
98 | /** |
||
99 | * @inheritDoc |
||
100 | */ |
||
101 | public function version(): string |
||
105 | |||
106 | /** |
||
107 | * Returns list of kernel bootstraps. |
||
108 | * This is a main place to tune default kernel behavior. |
||
109 | * Change carefully, as it may cause kernel failure. |
||
110 | * |
||
111 | * @return string[] |
||
112 | */ |
||
113 | protected function getBootstraps(): array |
||
129 | |||
130 | /** |
||
131 | * Invokes kernel bootstrap. |
||
132 | * This is the point where specific kernel functionality defined by bootstrap is enabled. |
||
133 | * |
||
134 | * @param string $bootstrapClass |
||
135 | * @param MutableContainer $container |
||
136 | * @throws InvalidArgumentException |
||
137 | */ |
||
138 | protected function invokeBootstrap(string $bootstrapClass, MutableContainer $container) |
||
144 | |||
145 | /** |
||
146 | * Returns a list of all registered service providers. |
||
147 | * |
||
148 | * @return string[] |
||
149 | */ |
||
150 | abstract protected function registerServiceProviders(): array; |
||
151 | |||
152 | /** |
||
153 | * Adds default service inflections. |
||
154 | * |
||
155 | * @param MutableContainer $container |
||
156 | */ |
||
157 | private function addDefaultInflections(MutableContainer $container) |
||
163 | |||
164 | /** |
||
165 | * Binds default services to container. |
||
166 | * |
||
167 | * @param MutableContainer $container |
||
168 | */ |
||
169 | private function bindDefaultServices(MutableContainer $container) |
||
174 | |||
175 | /** |
||
176 | * Ensures bootstrap class extends abstract kernel bootstrap. |
||
177 | * |
||
178 | * @param string $bootstrapClass |
||
179 | * @throws InvalidArgumentException |
||
180 | */ |
||
181 | private function ensureBootstrap(string $bootstrapClass) |
||
189 | |||
190 | /** |
||
191 | * Ensures service provider implements contract. |
||
192 | * |
||
193 | * @param string $providerClass |
||
194 | * @throws InvalidArgumentException |
||
195 | */ |
||
196 | private function ensureServiceProvider(string $providerClass) |
||
204 | |||
205 | /** |
||
206 | * Initializes service container. |
||
207 | */ |
||
208 | private function initServiceContainer(): MutableContainer |
||
218 | } |