> Hey AD7six, thanks for your very detailed answer!
>
> > You seem to have tens or hunderds of methods in your controllers e,g,
>
> Yes, that's true, I'm working on renaming them to protected ones using
> "_" as prefix.
>
> > isSuperuser <- user model
> > afterView <- model
> > OR
> > if more relevant just put it in the action, where's the benfit of
> > having 2 view functions
>
> I don't really understand. isSuperuser should be a model method, I
> agree with this, too. But what about afterView being a model method?
> In my concrete scenario, I have an AppController::view() method that
> handles all the view logic for every descending controller, and in the
> end of this view method the afterView() method is called, so
> descending controllers can do some magic in them (I'm using the
> Template pattern here).
what's wrong with
function view($id = null) {
parent::view($id);
// stuff that was in afterView
}
It depends quite a bit on what's in it and IME having generic app
controller actions and logic similar to the above eventually
complicates, not simplifies, code.
>
> So what about "put it in the action" and having 2 view functions?
>
> > _ = protected, __ = private. It's a convetion for php4 compatibility,
> > and it doesn't make any difference (but I'd suggest you only use
> > protected).
>
> I guess I'll only use one underscore. I never worked with strictly
> visibility enforcing languages like Java too long, so I don't really
> have the "feeling" on when a method should be private or protected,
> anyway.
If in doubt, you want protected. Also note people often say private
when they really mean protected. a private function cannot be called
from a descendant object - e.g. with your current code if afterFind
was declared private in the app controller and you haven't overwritten
it in your descendent controller - you can't access it and php will
die telling you so.
hth,
AD
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