1 | <?php |
||
21 | class Framework { |
||
22 | /** |
||
23 | * Flag whether the framework has been booted |
||
24 | * |
||
25 | * @var boolean |
||
26 | */ |
||
27 | protected static $booted = false; |
||
28 | |||
29 | /** |
||
30 | * IoC container |
||
31 | * |
||
32 | * @var Container |
||
33 | */ |
||
34 | protected static $container = null; |
||
35 | |||
36 | /** |
||
37 | * Array of framework service providers |
||
38 | * |
||
39 | * @var string[] |
||
40 | */ |
||
41 | protected static $service_proviers = [ |
||
42 | RoutingServiceProvider::class, |
||
43 | FlashServiceProvider::class, |
||
44 | OldInputServiceProvider::class, |
||
45 | TemplatingServiceProvider::class, |
||
46 | ControllersServiceProvider::class, |
||
47 | ]; |
||
48 | |||
49 | /** |
||
50 | * Get whether WordPress is in debug mode |
||
51 | * |
||
52 | * @return boolean |
||
53 | */ |
||
54 | 1 | public static function debugging() { |
|
59 | |||
60 | /** |
||
61 | * Get whether the framework has been booted |
||
62 | * |
||
63 | * @return boolean |
||
64 | */ |
||
65 | 1 | public static function isBooted() { |
|
68 | |||
69 | /** |
||
70 | * Throw an exception if the framework has not been booted |
||
71 | * |
||
72 | * @codeCoverageIgnore |
||
73 | * @throws Exception |
||
74 | * @return void |
||
75 | */ |
||
76 | protected static function verifyBoot() { |
||
81 | |||
82 | /** |
||
83 | * Get the IoC container instance |
||
84 | * |
||
85 | * @return Container |
||
86 | */ |
||
87 | 2 | public static function getContainer() { |
|
95 | |||
96 | /** |
||
97 | * Boot the framework |
||
98 | * WordPress's 'after_setup_theme' action is a good place to call this |
||
99 | * |
||
100 | * @codeCoverageIgnore |
||
101 | * @param array $config |
||
102 | * @throws Exception |
||
103 | * @return void |
||
104 | */ |
||
105 | public static function boot( $config = [] ) { |
||
123 | |||
124 | /** |
||
125 | * Load config into the service container |
||
126 | * |
||
127 | * @param Container $container |
||
128 | * @param array $config |
||
129 | * @return void |
||
130 | */ |
||
131 | protected static function loadConfig( Container $container, $config ) { |
||
137 | |||
138 | /** |
||
139 | * Register and boot all service providers |
||
140 | * |
||
141 | * @codeCoverageIgnore |
||
142 | * @param Container $container |
||
143 | * @return void |
||
144 | */ |
||
145 | protected static function loadServiceProviders( Container $container ) { |
||
163 | |||
164 | /** |
||
165 | * Register all service providers |
||
166 | * |
||
167 | * @codeCoverageIgnore |
||
168 | * @param \Obsidian\ServiceProviders\ServiceProviderInterface[] $service_providers |
||
169 | * @param Container $container |
||
170 | * @return void |
||
171 | */ |
||
172 | protected static function registerServiceProviders( $service_providers, Container $container ) { |
||
177 | |||
178 | /** |
||
179 | * Boot all service providers |
||
180 | * |
||
181 | * @codeCoverageIgnore |
||
182 | * @param \Obsidian\ServiceProviders\ServiceProviderInterface[] $service_providers |
||
183 | * @param Container $container |
||
184 | * @return void |
||
185 | */ |
||
186 | protected static function bootServiceProviders( $service_providers, Container $container ) { |
||
191 | |||
192 | /** |
||
193 | * Register a facade class |
||
194 | * |
||
195 | * @param string $alias |
||
196 | * @param string $facade_class |
||
197 | * @return void |
||
198 | */ |
||
199 | 1 | public static function facade( $alias, $facade_class ) { |
|
202 | |||
203 | /** |
||
204 | * Resolve a dependency from the IoC container |
||
205 | * |
||
206 | * @param string $key |
||
207 | * @return mixed|null |
||
208 | */ |
||
209 | 2 | public static function resolve( $key ) { |
|
218 | |||
219 | /** |
||
220 | * Create and return a class instance |
||
221 | * |
||
222 | * @param string $class |
||
223 | * @return object |
||
224 | */ |
||
225 | 2 | public static function instantiate( $class ) { |
|
236 | |||
237 | /** |
||
238 | * Send output based on a response object |
||
239 | * |
||
240 | * @codeCoverageIgnore |
||
241 | * @param ResponseInterface $response |
||
242 | * @return void |
||
243 | */ |
||
244 | public static function respond( ResponseInterface $response ) { |
||
247 | } |
||
248 |