I know that CakePHP applies some magic to inheritance. So when having
a class...
class AppController extends Controller {
var $uses = array('Model', 'AnotherModel');
}
...and then extending another one from it...
class AnotherController extends AppController {
var $uses = array('YetAnotherModel');
}
...we don't end up with AnotherController::uses being...
array('YetAnotherModel')
...(as PHP would normally do it), but with
array('Model', 'AnotherModel', 'YetAnotherModel')
This is very nice! But I wonder how I can use this magic for my own
class variables? E.g. I want AppController::filters to be
array('Filter1', 'Filter2') and then for UsersController I want to add
'Filter3', then normally I would have to use the beforeFilter:
UsersController extends AppController {
function beforeFilter() {
$this->filters[] = 'Filter3';
}
}
But this isn't very beautiful, so I'd rather use the CakePHP magic
mentioned above. But how could I do this? Is there an easy way to tell
CakePHP to treat "filters" the same way as "uses" etc.?
Thanks a lot for help
Josh
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
No comments:
Post a Comment