Beispiel #1
0
 /**
  * Send comment notification
  *
  * @param Newscoop\Entity\Comment $comment
  * @param Article $article
  * @param array $authors
  * @param Newscoop\Entity\User $user
  * @return void
  */
 public function sendCommentNotification(Comment $comment, \Article $article, array $authors, User $user = null)
 {
     $emails = array_unique(array_filter(array_map(function ($author) {
         return $author->getEmail();
     }, $authors)));
     if (empty($emails)) {
         return;
     }
     $this->view->placeholder(self::PLACEHOLDER_SUBJECT)->set('New Comment');
     $message = $this->view->action('comment-notify', 'email', 'default', array('comment' => $comment, 'article' => $article, 'user' => $user));
     $mail = new \Zend_Mail(self::CHARSET);
     $mail->setSubject($this->view->placeholder(self::PLACEHOLDER_SUBJECT));
     $mail->setBodyHtml($message);
     $mail->setFrom($user ? $user->getEmail() : $this->config['from']);
     foreach ($emails as $email) {
         $mail->addTo($email);
     }
     $mail->send();
 }