Hi all!
If I have a requirement, like a method that retrieves an specif model (or many) that needs to be used by many actions from many controllers.
where should I put this method?
For instance, I don’t agree to put “findRecentComments” method inside Comment ActiveRecord.
Why?
If a instantiate a new comment, this object should not know nothing about recent comments.
Because, it is a simple new entry from the database and it isn’t persisted yet inside it.
Even if it was, it should know just about itself, it is unique, it is an object that should know, retrive, manage ALL, but just about itself or another related objects
there should be a place who can manipulate these scenarios.
I can put a method like this inside the controller that managers the model that I’m needing.
So, how can I use, in Yii, a method of a controller if Im in another action from another controller?
more, in heavy applications i could have too many actions for a controller (model) and it would make the code less unreadble, and I’d have to do a refactoring because i could have a class with hundreds of code lines. (see Marting Flower)
that´s an observation that we can put in the documentation.