I’m currently refactoring my project and really need some fresh ideas on how to implement certain stuff.
I have frontend module containing account and profile management controllers. Things are designed quite well
till the moment I created frontend’s submodule (call it blog) having it’s own account & profile properties.
Currently frontend/blog/ProfileController duplicates certain code of frontend/ProfileController, uses extended
model and extended view (all copy some code from the frontend/ProfileController). I need some elegant solution on
how to inherit one controller fron another counting models and views. I’ve got some ideas but none of them are simple and clean enough. So, am kindly asking for your help.
How about creating a BaseFrontendController which contains all shared functions? Then you could extend ProfileController and others from BaseFrontendController.
Sounds reasonable, but I’m not sure this will ever solve view/model inheritance. Will still need to copy my code.
Controller inheritance isn’t that big deal. To avoid this move, we can simply create a ‘modelClass’ property and
change it to an inherited model when nessesary. The most hard thing are views. As far as I remember, in 1.1 we have CForm. Does it implement a builder pattern so I could inherit form views?