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'));
            }
        }
}

  

原文地址:https://www.cnblogs.com/sonicit/p/4557787.html