I want to implement a plug-in (hook) architecture inside my app.
I was thinking at something like
Yii::import('...'); // import plug-ins
public function myMethod()
{
$this->raiseEvent('onBeginMyMethod', new CEvent($this)); // execute before
... // method code
$this->raiseEvent('onEndMyMethod', new CEvent($this)); // execute after
}
for every method, so I can add code before/after their execution.
What do you think about this? Is there a more elegant way?
Is there a way I could stop the execution of myMethod() after invoking the first event (from the invoked function itself)? So I can also "override" the original method by using the onBegin event and then stopping the flow.