① 首先需要在src/AppBundle/Extensions/NotificationTemplate/文件目录下写好通知模板
通知模板② 在Service层写好调用创建通知的方法
例:
public function reviewTrain($id, $field, $reason='')
{
$type = "reviewRejected";
if (empty($reason)) {
$type = 'published';
}
$train=$this->getOfflineTrainDao()->get($id);
$content = ['type' => $type, "title" => $train['trainTitle'], "reason" => $reason];
$this->getNotificationService()->notify($train['creatorId'], 'offline-train-audit', $content);
// 三个参数分别代表着: 被通知的用户id, 通知类型(即他用的模板名), 通知模板所需要的参数组
return $this->getOfflineTrainDao()->update($id, $field);
}
/**
* @return NotificationServiceImpl
*/
protected function getNotificationService()
{
return $this->createService('User:NotificationService');
}
网友评论