/**
  * Assigns the currently logged in user to a Comment.
  *
  * @param  \FOS\CommentBundle\Event\CommentEvent $event
  * @return void
  */
 public function blame(CommentEvent $event)
 {
     $comment = $event->getComment();
     if (null === $this->securityContext) {
         if ($this->logger) {
             $this->logger->debug("Comment Blamer did not receive the security.context service.");
         }
         return;
     }
     if (!$comment instanceof SignedCommentInterface) {
         if ($this->logger) {
             $this->logger->debug("Comment does not implement SignedCommentInterface, skipping");
         }
         return;
     }
     if (null === $this->securityContext->getToken()) {
         if ($this->logger) {
             $this->logger->debug("There is no firewall configured. We cant get a user.");
         }
         return;
     }
     if (null === $comment->getAuthor() && $this->securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
         $comment->setAuthor($this->securityContext->getToken()->getUser());
     }
 }
 /**
  * Disallows comments in a closed thread.
  *
  * @param \FOS\CommentBundle\Event\CommentEvent $event
  */
 public function onCommentPersist(CommentEvent $event)
 {
     $comment = $event->getComment();
     $thread = $comment->getThread();
     if (!$thread->isCommentable()) {
         throw new PreconditionFailedHttpException('Cannot add comment to a closed thread');
     }
 }
 /**
  * Parses raw comment data and assigns it to the rawBody
  * property.
  *
  * @param \FOS\CommentBundle\Event\CommentEvent $event
  */
 public function markup(CommentEvent $event)
 {
     $comment = $event->getComment();
     if (!$comment instanceof RawCommentInterface) {
         return;
     }
     $result = $this->parser->parse($comment->getBody());
     $comment->setRawBody($result);
 }
 /**
  * Increase the thread comments number
  *
  * @param \FOS\CommentBundle\Event\CommentEvent $event
  */
 public function onCommentPersist(CommentEvent $event)
 {
     $comment = $event->getComment();
     if (!$this->commentManager->isNewComment($comment)) {
         return;
     }
     $thread = $comment->getThread();
     $thread->incrementNumComments(1);
     $thread->setLastCommentAt($comment->getCreatedAt());
 }
 /**
  * Assigns the currently logged in user to a Comment.
  *
  * @param \FOS\CommentBundle\Event\CommentEvent $event
  */
 public function blame(CommentEvent $event)
 {
     $comment = $event->getComment();
     if (!$comment instanceof SignedCommentInterface) {
         if ($this->logger) {
             $this->logger->debug("Comment does not implement SignedCommentInterface, skipping");
         }
         return;
     }
     if (null === $this->tokenStorage->getToken()) {
         if ($this->logger) {
             $this->logger->debug("There is no firewall configured. We cant get a user.");
         }
         return;
     }
     if (null === $comment->getAuthor() && $this->authorizationChecker->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
         $comment->setAuthor($this->tokenStorage->getToken()->getUser());
     }
 }