17f002eaf81c4569a4596b99e641ad460e3758c6
[zf2.biz/application_blanche.git] / module / Application / src / Application / Controller / ErrorController.php
1 <?php
2
3 namespace Application\Controller;
4
5 use Zend\Mvc\Controller\ActionController;
6
7 class ErrorController extends ActionController
8 {
9     const ERROR_NO_ROUTE = 404;
10     const ERROR_NO_CONTROLLER = 404;
11
12     public function indexAction()
13     {
14         $error = $this->request->getMetadata('error', false);
15         if (!$error) {
16             $error = array(
17                 'type'    => 404,
18                 'message' => 'Page not found',
19             );
20         }
21         
22         switch ($error['type']) {
23             case self::ERROR_NO_ROUTE:
24             case self::ERROR_NO_CONTROLLER:
25             default:
26                 // 404 error -- controller or action not found
27                 $this->response->setStatusCode(404);
28                 break;
29         }
30         
31         return array('message' => $error['message']);
32     }
33 }