コード例 #1
0
ファイル: CommentAction.php プロジェクト: blump/Comment
 /**
  * Notify shop managers of a new comment.
  * @param CommentCreateEvent $event
  */
 public function notifyAdminOfNewComment(CommentCreateEvent $event)
 {
     $config = \Comment\Comment::getConfig();
     if (!$config["notify_admin_new_comment"]) {
         return;
     }
     $comment = $event->getComment();
     if ($comment === null) {
         return;
     }
     // get the default shop locale
     $shopLang = LangQuery::create()->findOneByByDefault(true);
     if ($shopLang !== null) {
         $shopLocale = $shopLang->getLocale();
     } else {
         $shopLocale = null;
     }
     $getCommentRefEvent = new CommentReferenceGetterEvent($comment->getRef(), $comment->getRefId(), $shopLocale);
     $event->getDispatcher()->dispatch(CommentEvents::COMMENT_REFERENCE_GETTER, $getCommentRefEvent);
     $this->mailer->sendEmailToShopManagers('new_comment_notification_admin', ['comment_id' => $comment->getId(), 'ref_title' => $getCommentRefEvent->getTitle(), 'ref_type_title' => $getCommentRefEvent->getTypeTitle()]);
 }