| ... | ... |
@@ -248,8 +248,11 @@ class Application{
|
| 248 | 248 |
} |
| 249 | 249 |
|
| 250 | 250 |
public function handle404($request){
|
| 251 |
+ if(!isset($request)){
|
|
| 252 |
+ $request = $this->request; |
|
| 253 |
+ } |
|
| 251 | 254 |
if(!$this->router->is_Match404() && ($action = $this->router->setMatch404($request))){
|
| 252 |
- $this->runAction($action); |
|
| 255 |
+ return $this->runAction($action); |
|
| 253 | 256 |
} |
| 254 | 257 |
else{
|
| 255 | 258 |
http_response_code(404); |
| ... | ... |
@@ -340,21 +343,21 @@ class Application{
|
| 340 | 343 |
$result = $action; |
| 341 | 344 |
} |
| 342 | 345 |
|
| 343 |
- // Handle the action result |
|
| 344 |
- if(isset($result)){
|
|
| 345 |
- $this->handleActionResult($result); |
|
| 346 |
- } |
|
| 346 |
+ return isset($result) ? $result : null; |
|
| 347 | 347 |
} |
| 348 | 348 |
|
| 349 | 349 |
public function run(){
|
| 350 | 350 |
// Check if routing path is found |
| 351 | 351 |
if($action = $this->router->match($this->request)){
|
| 352 |
- $this->runAction($action); |
|
| 352 |
+ $result = $this->runAction($action); |
|
| 353 | 353 |
} |
| 354 | 354 |
// routing path not found -> generate 404 response |
| 355 | 355 |
else{
|
| 356 |
- $this->handle404($this->request); |
|
| 356 |
+ $result = $this->handle404($this->request); |
|
| 357 |
+ } |
|
| 358 |
+ // Handle the action result |
|
| 359 |
+ if(isset($result)){
|
|
| 360 |
+ $this->handleActionResult($result); |
|
| 357 | 361 |
} |
| 358 |
- |
|
| 359 | 362 |
} |
| 360 | 363 |
} |
| 361 | 364 |
\ No newline at end of file |