Hi,
In many of the widget-type extensions that I develop I find myself repeating a similar piece of code that looks like this:
class SomeWidget extends CWidget {
private $_isInitialized = false;
public function init() {
if ($all_conditions_met) {
$this->_isInitialized = true
}
}
public function run() {
if (!$this->_isInitialized) {
// log, throw exception or otherwise explode on this - depending on your needed biz logic.
// the main thing - abort execution of run() at the beginning, if CWidget determined 'not initialized'
}
}
I haven’t found something ready in CWidget that I can use. Is there?
If not, I think this is worth implementing. I haven’t thought really where this could be inserted. Are there filters for CWidgets? If so, this could certainly be in some default filter method in CWidget itself. This should be automatic as possible, preferrably without a need to call ‘parent::init()’ etc.
What do you think?