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