tags:

views:

23

answers:

1

I have the following 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();
 }

}
+7  A: 

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 :)

Dan Heberden
Thanks! I'll give it a shot. I was following documentation (though I can't find it again now) with the function callback above.
paullb
Worked perfectly, I guess the documentation I had was old. Works great now!
paullb