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 | * @inheritDoc |
||
41 | */ |
||
42 | public function boot(): Container |
||
71 | |||
72 | /** |
||
73 | * @inheritDoc |
||
74 | */ |
||
75 | public function environment(): string |
||
79 | |||
80 | /** |
||
81 | * @inheritDoc |
||
82 | */ |
||
83 | public function isCli(): bool |
||
87 | |||
88 | /** |
||
89 | * @return string |
||
90 | */ |
||
91 | abstract public function rootPath(): string; |
||
92 | |||
93 | /** |
||
94 | * @inheritDoc |
||
95 | */ |
||
96 | public function version(): string |
||
100 | |||
101 | /** |
||
102 | * Returns list of kernel bootstraps. |
||
103 | * This is a main place to tune default kernel behavior. |
||
104 | * Change carefully, as it may cause kernel failure. |
||
105 | * |
||
106 | * @return string[] |
||
107 | */ |
||
108 | protected function getBootstraps(): array |
||
124 | |||
125 | /** |
||
126 | * Invokes kernel bootstrap. |
||
127 | * This is the point where specific kernel functionality defined by bootstrap is enabled. |
||
128 | * |
||
129 | * @param string $bootstrapClass |
||
130 | * @param MutableContainer $container |
||
131 | * @throws InvalidArgumentException |
||
132 | */ |
||
133 | protected function invokeBootstrap(string $bootstrapClass, MutableContainer $container) |
||
139 | |||
140 | /** |
||
141 | * Returns a list of all registered service providers. |
||
142 | * |
||
143 | * @return string[] |
||
144 | */ |
||
145 | abstract protected function registerServiceProviders(): array; |
||
146 | |||
147 | /** |
||
148 | * Adds default service inflections. |
||
149 | * |
||
150 | * @param MutableContainer $container |
||
151 | */ |
||
152 | private function addDefaultInflections(MutableContainer $container) |
||
158 | |||
159 | /** |
||
160 | * Binds default services to container. |
||
161 | * |
||
162 | * @param MutableContainer $container |
||
163 | */ |
||
164 | private function bindDefaultServices(MutableContainer $container) |
||
169 | |||
170 | /** |
||
171 | * Ensures bootstrap class extends abstract kernel bootstrap. |
||
172 | * |
||
173 | * @param string $bootstrapClass |
||
174 | * @throws InvalidArgumentException |
||
175 | */ |
||
176 | private function ensureBootstrap(string $bootstrapClass) |
||
184 | |||
185 | /** |
||
186 | * Ensures service provider implements contract. |
||
187 | * |
||
188 | * @param string $providerClass |
||
189 | * @throws InvalidArgumentException |
||
190 | */ |
||
191 | private function ensureServiceProvider(string $providerClass) |
||
199 | |||
200 | /** |
||
201 | * Initializes service container. |
||
202 | */ |
||
203 | private function initServiceContainer(): MutableContainer |
||
213 | } |