1 | <?php |
||
25 | class BaseApp extends Container |
||
26 | { |
||
27 | /** |
||
28 | * @const string |
||
29 | */ |
||
30 | const CHARSET = 'UTF-8'; |
||
31 | |||
32 | /** |
||
33 | * @var Config |
||
34 | */ |
||
35 | protected $config; |
||
36 | |||
37 | /** |
||
38 | * @var string |
||
39 | */ |
||
40 | protected $environment; |
||
41 | |||
42 | /** |
||
43 | * @var ServiceProviderInterface[] |
||
44 | */ |
||
45 | protected $providers = []; |
||
46 | |||
47 | /** |
||
48 | * @var bool |
||
49 | */ |
||
50 | protected $booted = false; |
||
51 | |||
52 | /** |
||
53 | * @var bool |
||
54 | */ |
||
55 | protected $isCli = false; |
||
56 | |||
57 | /** |
||
58 | * Constructor. |
||
59 | * |
||
60 | * @param array|Config $config |
||
61 | * @param string $environment Defaults to "production" |
||
62 | */ |
||
63 | 21 | public function __construct($config = [], $environment = 'production') |
|
75 | |||
76 | /** |
||
77 | * Initializes the application object. |
||
78 | |||
79 | * Override and put initialization code that should always be run as early as |
||
80 | * possible here, but make sure no objects are actually instanced here, because then |
||
81 | * mock objects can't be injected in their place. Place object instance code in |
||
82 | * the preHandle method. |
||
83 | */ |
||
84 | 21 | protected function init() |
|
94 | |||
95 | /** |
||
96 | * Register service providers. |
||
97 | */ |
||
98 | 21 | protected function registerProviders() |
|
103 | |||
104 | /** |
||
105 | * Register service provider. |
||
106 | * |
||
107 | * @param ServiceProviderInterface $provider |
||
108 | */ |
||
109 | 21 | public function register(ServiceProviderInterface $provider) |
|
115 | |||
116 | /** |
||
117 | * @param array $phpSettings |
||
118 | * @param string $prefix |
||
119 | */ |
||
120 | 21 | protected function setPhpSettings($phpSettings, $prefix = '') |
|
131 | |||
132 | /** |
||
133 | * Boot the application and its service providers. |
||
134 | * |
||
135 | * This is normally called by handle(). If requests are not handled |
||
136 | * this method will have to called manually to boot. |
||
137 | */ |
||
138 | 5 | public function boot() |
|
152 | |||
153 | /** |
||
154 | * Pre handle method meant to be overridden in descendant classes (optional). |
||
155 | * |
||
156 | * This method is called before an request is handled. Object instance code should be |
||
157 | * place here and not in init() (more info about this at init()). |
||
158 | * |
||
159 | * @param Request $request |
||
160 | * @return Response|null |
||
161 | */ |
||
162 | 3 | protected function preHandle(Request $request) |
|
166 | |||
167 | /** |
||
168 | * Post route method meant to be overridden in descendant classes (optional). |
||
169 | * This method is called before an request is dispatched but after it's routed. This means that we know |
||
170 | * it's a valid route and have access to the route attributes at this stage. |
||
171 | * |
||
172 | * @param Request $request |
||
173 | * @return Response|null |
||
174 | */ |
||
175 | 1 | protected function postRoute(Request $request) |
|
179 | |||
180 | /** |
||
181 | * Handles an http request and returns a response. |
||
182 | * |
||
183 | * @param Request $request |
||
184 | * @return Response |
||
185 | */ |
||
186 | 4 | public function handle(Request $request) |
|
213 | |||
214 | /** |
||
215 | * Returns a response for no route / resource not found. |
||
216 | * |
||
217 | * @param Request $request |
||
218 | * @return Response |
||
219 | */ |
||
220 | 1 | protected function getNoRouteResponse(Request $request) |
|
224 | |||
225 | /** |
||
226 | * Post handle method meant to be overridden in descendant classes (optional). |
||
227 | * This method is called after an request has been handled but before |
||
228 | * the response is returned from the handle method. |
||
229 | * |
||
230 | * @param Request $request |
||
231 | */ |
||
232 | 2 | protected function postHandle(Request $request) |
|
235 | |||
236 | /** |
||
237 | * @return Config |
||
238 | */ |
||
239 | 21 | public function getConfig() |
|
243 | |||
244 | /** |
||
245 | * @return bool |
||
246 | */ |
||
247 | 21 | public function isCli(): bool |
|
251 | |||
252 | /** |
||
253 | * @return Request|null |
||
254 | */ |
||
255 | public function getRequest() |
||
259 | |||
260 | /** |
||
261 | * @return string |
||
262 | */ |
||
263 | 1 | public function getEnvironment() |
|
267 | } |
||
268 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.