/**
  * {@inheritDoc}
  */
 public function addThread(ThreadInterface $thread)
 {
     if (!$this->threadAcl->canCreate()) {
         throw new AccessDeniedException();
     }
     $this->realManager->addThread($thread);
 }
 /**
  * {@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 saveThread(ThreadInterface $thread)
 {
     if (!$this->threadAcl->canCreate()) {
         throw new AccessDeniedException();
     }
     $newThread = $this->isNewThread($thread);
     if (!$newThread && !$this->threadAcl->canEdit($thread)) {
         throw new AccessDeniedException();
     }
     $this->realManager->saveThread($thread);
     if ($newThread) {
         $this->threadAcl->setDefaultAcl($thread);
     }
 }
 /**
  * {@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);
     }
 }