Yii 中有没有办法在函数被触发时捕获并处理所有传入的请求。我想纠正一个电子邮件扩展名,该扩展名可以设置为诸如"当触发文档/更新"或"保存文档"功能被触发发送电子邮件x时。
我想我可以通过扩展控制器类来做到这一点,但这已经由权限扩展完成。
感谢您的任何建议。
创建一个类过滤器 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();
}
}
在控制器中
public function filters()
{
return array(
'application.filters.EmailFilter + update,saveDocument'// apply filter on update and saveDocument action only
);
}