1

Yii 有没有办法在函数被触发时捕获并处理所有传入的请求。我想纠正一个可以设置为类似的电子邮件扩展名,当文档/更新被触发或功能 SaveDocument 被触发时发送电子邮件 x。

我猜我可以通过扩展 Controller 类来做到这一点,但这已经通过权限扩展来完成。

感谢您的任何建议。

4

1 回答 1

4

创建一个类过滤器 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
 );
 }
于 2012-04-17T22:25:04.603 回答