/**
  *
  * @access public
  * @param  \CCDNForum\ForumBundle\Entity\Post              $post
  * @return \CCDNForum\ForumBundle\Manager\ManagerInterface
  */
 public function savePost(Post $post)
 {
     $this->postLockHelper->setLockLimitOnPost($post);
     $this->gateway->savePost($post);
     // refresh the user so that we have an PostId to work with.
     $this->refresh($post);
     return $this;
 }
 public function canEditPost(Post $post, Forum $forum = null)
 {
     if (!$this->securityContext->isGranted('ROLE_USER')) {
         return false;
     }
     if (!$this->canShowPost($post, $forum) && !$this->securityContext->isGranted('ROLE_ADMIN')) {
         return false;
     }
     if ($this->postLockHelper->isLocked($post)) {
         if (!$this->securityContext->isGranted('ROLE_MODERATOR')) {
             return false;
         }
     }
     if (!$this->securityContext->isGranted('ROLE_ADMIN')) {
         if (!$post->getCreatedBy()) {
             return false;
         } else {
             if ($post->getCreatedBy()->getId() != $this->securityContext->getToken()->getUser()->getId()) {
                 return false;
             }
         }
     }
     return true;
 }