예제 #1
0
 /**
  * {@inheritDoc}
  */
 public function addComment(CommentInterface $comment, CommentInterface $parent = null)
 {
     if (!$this->threadAcl->canView($comment->getThread())) {
         throw new AccessDeniedException();
     }
     if (!$this->commentAcl->canReply($parent)) {
         throw new AccessDeniedException();
     }
     $this->realManager->addComment($comment, $parent);
     $this->commentAcl->setDefaultAcl($comment);
 }
 /**
  * {@inheritDoc}
  */
 public function saveComment(CommentInterface $comment)
 {
     if (!$this->threadAcl->canView($comment->getThread())) {
         throw new AccessDeniedException();
     }
     if (!$this->commentAcl->canReply($comment->getParent())) {
         throw new AccessDeniedException();
     }
     $newComment = $this->isNewComment($comment);
     if (!$newComment && !$this->commentAcl->canEdit($comment)) {
         throw new AccessDeniedException();
     }
     if (($comment::STATE_DELETED === $comment->getState() || $comment::STATE_DELETED === $comment->getPreviousState()) && !$this->commentAcl->canDelete($comment)) {
         throw new AccessDeniedException();
     }
     $this->realManager->saveComment($comment);
     if ($newComment) {
         $this->commentAcl->setDefaultAcl($comment);
     }
 }