| Conditions | 3 |
| Paths | 2 |
| Total Lines | 22 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 24 | public function statusCodeAction($code = null, $message = null) |
||
| 25 | { |
||
| 26 | $codes = [ |
||
| 27 | 403 => "403 Forbidden", |
||
| 28 | 404 => "404 Not Found", |
||
| 29 | 500 => "500 Internal Server Error", |
||
| 30 | ]; |
||
| 31 | |||
| 32 | // Key being integer also (unintentionally) prevents this action from direct url usage |
||
| 33 | if (!$code || !in_array($code, $codes)) { |
||
| 34 | throw new \Anax\Exception\NotFoundException("Not a valid HTTP status code."); |
||
| 35 | } |
||
| 36 | |||
| 37 | $title = $codes[$code]; |
||
| 38 | $this->di->response->setHeader($code); |
||
| 39 | $this->di->theme->setTitle($title); |
||
| 40 | $this->di->views->add('default/error', [ |
||
| 41 | 'title' => $title, |
||
| 42 | 'content' => $message, |
||
| 43 | 'details' => $this->di->flash->getMessage(), |
||
| 44 | ]); |
||
| 45 | } |
||
| 46 | } |
||
| 47 |