1 | <?php declare(strict_types=1); |
||
20 | class BaseApp extends Container |
||
21 | { |
||
22 | /** |
||
23 | * @const string |
||
24 | */ |
||
25 | const CHARSET = 'UTF-8'; |
||
26 | |||
27 | /** |
||
28 | * @var Config |
||
29 | */ |
||
30 | protected $config; |
||
31 | |||
32 | /** |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $environment; |
||
36 | |||
37 | /** |
||
38 | * @var ServiceProviderInterface[] |
||
39 | */ |
||
40 | protected $providers = []; |
||
41 | |||
42 | /** |
||
43 | * @var bool |
||
44 | */ |
||
45 | protected $booted = false; |
||
46 | |||
47 | /** |
||
48 | * @var bool |
||
49 | */ |
||
50 | protected $isCli = false; |
||
51 | |||
52 | /** |
||
53 | * Constructor. |
||
54 | * |
||
55 | * @param array|Config $config |
||
56 | * @param string $environment Defaults to "production" |
||
57 | */ |
||
58 | 22 | public function __construct(array $config = [], string $environment = 'production') |
|
70 | |||
71 | /** |
||
72 | * Initializes the application object. |
||
73 | |||
74 | * Override and put initialization code that should always be run as early as |
||
75 | * possible here, but make sure no objects are actually instanced here, because then |
||
76 | * mock objects can't be injected in their place. Place object instance code in |
||
77 | * the preHandle method. |
||
78 | */ |
||
79 | 22 | protected function init(): void |
|
89 | |||
90 | 22 | protected function registerProviders(): void |
|
95 | |||
96 | 22 | public function register(ServiceProviderInterface $provider): void |
|
102 | |||
103 | 22 | protected function setPhpSettings(array $phpSettings, string $prefix = ''): void |
|
114 | |||
115 | /** |
||
116 | * Boot the application and its service providers. |
||
117 | * |
||
118 | * This is normally called by handle(). If requests are not handled |
||
119 | * this method will have to called manually to boot. |
||
120 | */ |
||
121 | 6 | public function boot(): void |
|
135 | |||
136 | /** |
||
137 | * Pre handle method meant to be overridden in descendant classes (optional). |
||
138 | * |
||
139 | * This method is called before an request is handled. Object instance code should be |
||
140 | * place here and not in init() (more info about this at init()). |
||
141 | * |
||
142 | * @param Request $request |
||
143 | * @return Response|null |
||
144 | */ |
||
145 | 3 | protected function preHandle(Request $request): ?Response |
|
149 | |||
150 | /** |
||
151 | * Post route method meant to be overridden in descendant classes (optional). |
||
152 | * This method is called before an request is dispatched but after it's routed. This means that we know |
||
153 | * it's a valid route and have access to the route attributes at this stage. |
||
154 | * |
||
155 | * @param Request $request |
||
156 | * @return Response|null |
||
157 | */ |
||
158 | 1 | protected function postRoute(Request $request): ?Response |
|
162 | |||
163 | /** |
||
164 | * Handles an http request and returns a response. |
||
165 | * |
||
166 | * @param Request $request |
||
167 | * @return Response |
||
168 | */ |
||
169 | 4 | public function handle(Request $request): Response |
|
196 | |||
197 | 1 | protected function getNoRouteResponse(Request $request): Response |
|
201 | |||
202 | /** |
||
203 | * Post handle method meant to be overridden in descendant classes (optional). |
||
204 | * This method is called after an request has been handled but before |
||
205 | * the response is returned from the handle method. |
||
206 | * |
||
207 | * @param Request $request |
||
208 | */ |
||
209 | 2 | protected function postHandle(Request $request): void |
|
212 | |||
213 | 22 | public function getConfig(): Config |
|
217 | |||
218 | 22 | public function isCli(): bool |
|
222 | |||
223 | 1 | public function getRequest(): ?Request |
|
227 | |||
228 | 1 | public function getEnvironment(): string |
|
232 | } |
||
233 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.