开发者

cakePHP - before_filter not executed

开发者 https://www.devze.com 2023-01-04 23:03 出处:网络
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 somethi

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

精彩评论

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

关注公众号