Controller_Abstract的改造

Controller_Abstract 是所有Controller的父类,改造它可以节省很多时间。

比如execute方法,execute是每个action执行时都在执行的方法。

function execute($action_name, array $args = array())
    {
        //如果action为login,imgcode,不判断登陆用户信息。省得在每个action中进行判断
        if (!in_array($this->_context->action_name, array("login", "imgcode"))){
            if (is_null($this->_app->currentUser())){
                return $this->_redirect(url('admin/login'));
            }
        }
}

  

posted @ 2015-06-07 10:22  sonicit  阅读(320)  评论(0编辑  收藏  举报