1 | <?php declare(strict_types = 1); |
||
26 | abstract class AbstractKernel implements Kernel |
||
27 | { |
||
28 | const VERSION = '0.1.0'; |
||
29 | |||
30 | /** |
||
31 | * Service container class name. |
||
32 | * |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $containerClass = \Venta\Container\Container::class; |
||
36 | |||
37 | /** |
||
38 | * @inheritDoc |
||
39 | */ |
||
40 | public function boot(): Container |
||
63 | |||
64 | /** |
||
65 | * @inheritDoc |
||
66 | */ |
||
67 | public function environment(): string |
||
71 | |||
72 | /** |
||
73 | * @inheritDoc |
||
74 | */ |
||
75 | public function isCli(): bool |
||
79 | |||
80 | /** |
||
81 | * @return string |
||
82 | */ |
||
83 | abstract public function rootPath(): string; |
||
84 | |||
85 | /** |
||
86 | * @inheritDoc |
||
87 | */ |
||
88 | public function version(): string |
||
92 | |||
93 | /** |
||
94 | * Boots service provider with base config. |
||
95 | * |
||
96 | * @param string $providerClass |
||
97 | * @param Container $container |
||
98 | * @param ConfigBuilderContract $configBuilder |
||
99 | * @throws InvalidArgumentException |
||
100 | */ |
||
101 | protected function bootServiceProvider( |
||
110 | |||
111 | /** |
||
112 | * Returns list of kernel bootstraps. |
||
113 | * This is a main place to tune default kernel behavior. |
||
114 | * Change carefully, as it may cause kernel failure. |
||
115 | * |
||
116 | * @return string[] |
||
117 | */ |
||
118 | protected function getBootstraps(): array |
||
134 | |||
135 | /** |
||
136 | * Invokes kernel bootstrap. |
||
137 | * This is the point where specific kernel functionality defined by bootstrap is enabled. |
||
138 | * |
||
139 | * @param string $bootstrapClass |
||
140 | * @param Container $container |
||
141 | * @throws InvalidArgumentException |
||
142 | */ |
||
143 | protected function invokeBootstrap(string $bootstrapClass, Container $container) |
||
149 | |||
150 | /** |
||
151 | * Returns a list of all registered service providers. |
||
152 | * |
||
153 | * @return string[] |
||
154 | */ |
||
155 | abstract protected function registerServiceProviders(): array; |
||
156 | |||
157 | /** |
||
158 | * Adds default service inflections. |
||
159 | * |
||
160 | * @param Container $container |
||
161 | */ |
||
162 | private function addDefaultInflections(Container $container) |
||
168 | |||
169 | /** |
||
170 | * Binds default services to container. |
||
171 | * |
||
172 | * @param Container $container |
||
173 | */ |
||
174 | private function bindDefaultServices(Container $container) |
||
179 | |||
180 | /** |
||
181 | * Ensures bootstrap class extends abstract kernel bootstrap. |
||
182 | * |
||
183 | * @param string $bootstrapClass |
||
184 | * @throws InvalidArgumentException |
||
185 | */ |
||
186 | private function ensureBootstrap(string $bootstrapClass) |
||
194 | |||
195 | /** |
||
196 | * Ensures service provider implements contract. |
||
197 | * |
||
198 | * @param string $providerClass |
||
199 | * @throws InvalidArgumentException |
||
200 | */ |
||
201 | private function ensureServiceProvider(string $providerClass) |
||
209 | |||
210 | /** |
||
211 | * Initializes service container. |
||
212 | */ |
||
213 | private function initServiceContainer(): Container |
||
223 | } |