Error.php
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/**
* @name ErrorController
* @desc 错误控制器, 在发生未捕获的异常时刻被调用
* @see http://www.php.net/manual/en/yaf-dispatcher.catchexception.php
* @author liuziyang
*/
use Action\RootAction;
class ErrorController extends RootAction
{
public function init()
{
$this->getView()->setLayout('error');
$this->_viewLink()->offsetSetFile(100, $this->_css('style.default', true));
}
public function errorAction($exception)
{
//YAF_ERR_NOTFOUND_VIEW
switch ($exception->getCode()) {
case 517:
case 516:
case 515:
//404
$this->redirect('/404.html');
break;
case 521:
case 520:
case 519:
case 518:
case 514:
case 513:
case 512:
$this->getView()->assign("exception", $exception);
break;
//break;
default:
//自定义的异常
$this->getView()->assign("exception", $exception);
}
}
public function indexAction()
{
}
public function notFoundAction()
{
header("Not Found");
}
public function alertAction()
{
$alertMessage = $this->_session('system_alert')->__get('alert_message');
$this->_assign('alertMessage', $alertMessage);
}
}