用户
 找回密码
 入住 CI 中国社区
搜索
查看: 1644|回复: 0
收起左侧

[版本 3.x] 自定义类库怎么使用$this->router->fetch_method()?

[复制链接]
发表于 2015-9-21 10:27:40 | 显示全部楼层 |阅读模式

这样报错,Unable to load the requested class: Router


正确的姿势应该是什么?



PHP复制代码
 
class Blesta
{
    protected $CI;
 
    public function __construct()
    {
        $this->CI =& get_instance();
    }
 
    // 需要登录继续
    public function require_login()
    {
        $this->CI->load->library('session');
        if((!$this->CI->session->userdata('user_id'))&&($this->router->fetch_method()!='login')){
            redirect('Login/index');
        }
        if(($this->CI->session->userdata('user_id'))&&($this->router->fetch_method()=='login')){
            redirect('Welcome/index');
        }
    }
}
 
 
复制代码

本版积分规则