Is there a way in Yii to catch and act upon all incoming requests are when functions are fired. I want to right an e-mail extension that can be set to something like, when documents/update is fired or function SaveDocument is fired send e-mail x.
I guessing that i can do this by extending the Controller class but that is already being done by the rights extension.
Thanks for any suggestions.
create a class filter protected/filter/EmailFilter
EmailFilter extends CFilter{
//fired before action
protected function preFilter($filterChain)
{
return true; // false if the action should not be executed
}
//fired after action
protected function postFilter()
{
sendEmail();
}
}
in your controller
public function filters()
{
return array(
'application.filters.EmailFilter + update,saveDocument'// apply filter on update and saveDocument action only
);
}