CakePHP 3:仅允许为管理员加载DebugKit

时间:2015-02-27 16:31:04

标签: cakephp cakephp-3.0 cakephp-debug-kit

我耗尽了我的资源,试图解决这个问题。我如何才能启用"非常有用" DebugKit仅在登录用户是管理员时加载?我知道并认为可行的方法是使用Configure::write('debug', 1),但它没有奏效。我不知道还能做什么...这是我目前在`AppController.php1文件中的代码

// AppController.php

public function beforeFilter(Event $event){
    parent::beforeFilter($event);

    // ...

    // Checks if loggedin user is an administrator
    if($this->Auth->user() && $this->Auth->user('role' == 'admin')){
        // Enable debugging and allow DebugKit to load
        Configure::write('debug', 1);
    }
}

0 个答案:

没有答案
相关问题