Tuesday, December 11, 2012

Re: Is overriding AppController's beforeFilter() always recommended ?

you can omit those methods if they dont do anything else except for calling the parent
the cookbook merely offers examples on how you would do it if you needed it

so yes, from an oop point of view, pretty useless


Am Dienstag, 11. Dezember 2012 22:02:46 UTC+1 schrieb alaxos:
While answering a recent question on stackoverflow (http://
stackoverflow.com/questions/13825073/always-call-a-function-in-
cakephp), I discovered that it seems to be recommended in the cookbook
to always override the AppController beforeFilter() in child
controllers (http://book.cakephp.org/2.0/en/controllers.html#the-app-
controller), even if it is only to call the AppController's
beforeFilter() method like this:

public function beforeFilter() {
    parent::beforeFilter();
}

My feeling is that in OO programming, this is useless, because if we
don't override a method in a child class, the parent method is used.

I do know that when the beforeFilter() method is not overridden in
child controllers, the AppController's beforeFilter() is indeed
called, but as it is recommended in the cookbook, is there any
advantage to do so ? Am I missing something here ?

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
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.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: