0

プロジェクトに Cakephp デバッグキット プラグインを実装しています。私の appcontroller.php ファイルに追加します

 var $helpers = array('Html', 'Form', 'Paginator', 'Js', 'Session'); 
 public $components = array('DebugKit.Toolbar');

 and in before filter i implement 
function beforeFilter() {
    if ($this->Session->check('GlobalFields')==false) {
    $this->Session->write('GlobalFields.tbl_assets.template_information_global', '');
    $this->Session->write('GlobalFields.tbl_assets.hilitelibrary', '');
    $this->Session->write('GlobalFields.tbl_assets.hilitesortedby', '');
    $this->Session->write('GlobalFields.tbl_assets.sc_url_prefix', '');
    }
}
   but it showing error 
   Fatal error: Call to a member function check() on a non-object.
   and i check that debug($this->Session) returns null.

 if i remove public $components = array('DebugKit.Toolbar'); then its run correctly.
 but i want to implement that debugkit with session.

この問題を解決するのを手伝ってください。

4

1 に答える 1

2

ここで何が起こるかは、次のように設定することです。

public $components = array('DebugKit.Toolbar');

SessionComponentを含むデフォルト値をオーバーライドしています。変数にSessionHelperをアタッチしてい$helpersますが、これら2つのクラスは異なります。最初のクラス(コンポーネント)ではコントローラー内のセッションデータを操作でき、2番目のクラス(ヘルパー)はビューで使用されます。

したがって、問題の解決策は次のように設定することです。

public $components = array('Session','DebugKit.Toolbar');

また、他のコンポーネントをグローバルに使用している場合は、それらもそこに追加する必要があります。

于 2012-12-27T13:48:22.337 に答える