Error.php 1.32 KB
<?php

/**
 * 错误错误控制器
 * 
 * @name ErrorController
 * @desc 错误控制器, 在发生未捕获的异常时刻被调用
 * @see //www.php.net/manual/en/yaf-dispatcher.catchexception.php
 */
use Action\WebAction;
use WebPlugin\Helpers;
use Index\HomeModel;

class ErrorController extends WebAction
{

    public function indexAction()
    {
        $this->setWebNavHeader();
        //$channel = HomeModel::getSwitchChannel();
        header('HTTP/1.1 404 Not Found');
        header('Status: 404 Not Found');
        $this->setTitle('页面不存在');
        //$this->_view->html('error_'.$channel);
        $this->_view->display('index', array('errorPage' => true,'newProductLink'=>  Helpers::url('/product/new')));
    }

    public function errorAction($exception)
    {
        $this->setWebNavHeader();
        $channel = HomeModel::getSwitchChannel();
        $this->setTitle('页面不存在');
        header('HTTP/1.1 404 Not Found');
        header('Status: 404 Not Found');
        
        // @todo debug
        // echo $exception->getMessage();
        // 生成HTML (error.html)
        //$this->_view->html('error_'.$channel);
        // 渲染模板
        $this->_view->display('index', array('errorPage' => true,'newProductLink'=>  Helpers::url('/product/new')));
    }
}