Basically, Yii has a bunch of objects instantiated like this for example:
new CEvent;
So check it. That means the bulk of the classes that make up the framework cannot be easily extended like these ones:
http://www.yiiframework.com/doc/guide/1.1/en/basics.application#core-application-components
aka, “CApplicationComponent” classes. It’s a pattern i use all the time for my own classes I want globally accessible from Yii::app(). It’s great for switching in your own extended versions of those classes in the main.php config file, etc. BUT, there are very many classes that can’t be extended that way. And often you have to go around and change 2-4 classes as a result that can be extended just so that everywhere ‘new CEvent’ is created, it’s creating ‘new CustomEvent’.
So wouldn’t it be possible to instantiate all objects via Yii::createComponent() rather than use the ‘new’ operator, and then in createComponent() add some code to dynamically search for replacement classes you specified in the main.php config file? It seems like a replace-all sort of job where you could replace all the objects instantiated with ‘new’ automatically to be instantiated with createComponent(). Or even it had to be done by hand, it doesn’t seem like it would take much time.
Am I alone here as the only one that’s extended 2+ additional classes so they instantiate objects from a new extended class???
Thoughts?