I have a controller that is starting to feel very bloated. Some of the actions themselves are very large and much as I try to split things up, navigating this file is getting tiresome.
I was wondering if there is any way, and specifically any convention, for managing very large controllers? Is there a way to split a controller up into easier-to-manage sections?
I see that there is a CAction class. Is this the way to go? What about methods that aren't actions?
Maybe your controller is bloated because it's doing things that should be sent to the model? Controllers should act as traffic cops. They respond to a request, gather the needed data (from various models), and then send that data to a view. Maybe your controller is doing some of the work that your model(s) should be doing?
I think you should read this link http://www.yiiframework.com/doc/guide/1.1/en/basics.best-practices to improve your structure with MVC
. Besides, If you want to make your controller be simple then you can use CAction. From http://www.yiiframework.com/doc/api/1.1/CAction:
CAction provides a way to divide a complex controller into smaller actions in separate class files.
To make your model be lean, you can use Behaviors
from Yii.