开发者

cakePHP - before_filter not executed

I have the fo开发者_如何学Pythonllowing app_controller in app/controller.

the test function is never executed. If I put in the subclassed controller, its not executed there either. am I doing something wrong?

class AppController extends Controller {
 var $beforeFilter = array('test');

 function test() {
  var_dump('test');
  die();
 }

}


beforeFilter should be the actual function, not a variable (like helpers or components)..

   class AppController extends Controller {
        function beforeFilter(){
           pr('test');
        }
    }

Too, in your controllers you should call

parent::beforeFilter();

in their beforeFilter function. Since this is a static function, it need be an actual function :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜