getComments() public method

public getComments ( )
Example #1
0
 /**
  * Send email to author and all people from comments when vote is Approved or Rejected
  *
  * @param Post   $post
  * @param string $translation
  * @param string $template
  */
 private function sendPostVoteClosedEmail(Post $post, $translation, $template)
 {
     $recipients[] = $post->getAuthor()->getEmail();
     /** @var Comment $comment */
     $comments = $post->getComments();
     foreach ($comments as $comment) {
         $recipients[] = $comment->getUser()->getEmail();
     }
     $subject = $this->translator->trans($translation);
     $body = $this->renderView($template, array('post' => $post));
     $this->mailer->send($recipients, $subject, $body);
 }
Example #2
0
 public function countCommentsWithRating(\Twig_Environment $twig, Post $post)
 {
     $comments = $post->getComments();
     $countCommentsWithRating = 0;
     if (count($comments) !== 0) {
         foreach ($comments as $comment) {
             if (0 !== $comment->getRating()) {
                 $countCommentsWithRating++;
             }
         }
     }
     return $countCommentsWithRating;
 }
 /**
  * {@inheritDoc}
  */
 public function getComments()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getComments', array());
     return parent::getComments();
 }