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 :)
精彩评论