1: <?php
2: namespace Application\Controller;
3: use Application\Controller\ApplicationController;
4:
5: /**
6: * ERROR CONTROLLER
7: *
8: * Controller for error
9: *
10: * @category Application
11: * @package Controller
12: * @author Nitesh Apte <me@niteshapte.com>
13: * @copyright 2015 Nitesh Apte
14: * @version 1.0.0
15: * @since 1.0.0
16: * @license https://www.gnu.org/licenses/gpl.txt GNU General Public License v3
17: *
18: * This program is free software: you can redistribute it and/or modify
19: * it under the terms of the GNU General Public License as published by
20: * the Free Software Foundation, either version 3 of the License, or
21: * (at your option) any later version.
22: *
23: * This program is distributed in the hope that it will be useful,
24: * but WITHOUT ANY WARRANTY; without even the implied warranty of
25: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26: * GNU General Public License for more details.
27: *
28: * You should have received a copy of the GNU General Public License
29: * along with this program. If not, see <http://www.gnu.org/licenses/>.
30: */
31: class ErrorController extends ApplicationController {
32:
33: /**
34: * Action for all errors
35: *
36: * @param number $error
37: * @return void
38: */
39: public function defaultAction($error = 404) {
40:
41: switch ($error) {
42: case 400:
43: $this->view->addObject("error", $this->lang['400']);
44: break;
45:
46: case 401:
47: $this->view->addObject("error", $this->lang['401']);
48: break;
49:
50: case 402:
51: $this->view->addObject("error", $this->lang['402']);
52: break;
53:
54: case 403:
55: $this->view->addObject("error", $this->lang['403']);
56: break;
57:
58: case 408:
59: $this->view->addObject("error", $this->lang['408']);
60: break;
61:
62: case 415:
63: $this->view->addObject("error", $this->lang['415']);
64: break;
65:
66: case 500:
67: $this->view->addObject("error", $this->lang['500']);
68: break;
69:
70: case 502:
71: $this->view->addObject("error", $this->lang['502']);
72: break;
73:
74: case 503:
75: $this->view->addObject("error", $this->lang['503']);
76: break;
77:
78: case 404:
79: default:
80: $this->view->addObject("error", $this->lang['404']);
81: break;
82: }
83: $this->view->addObject("title", $error);
84: $this->view->render('error');
85: }
86: }