/**
  *
  * @access public
  * @param  \CCDNForum\ForumBundle\Entity\Topic             $topic
  * @param  int                                             $userId
  * @return \CCDNForum\ForumBundle\Manager\ManagerInterface
  */
 public function unsubscribe(Topic $topic, $userId)
 {
     $subscription = $this->model->findOneSubscriptionForTopicByIdAndUserById($topic->getId(), $userId);
     if (!$subscription) {
         return $this;
     }
     $subscription->setSubscribed(false);
     $subscription->setRead(true);
     $this->gateway->saveSubscription($subscription);
     return $this;
 }
 /**
  *
  * @access public
  * @param  \CCDNForum\ForumBundle\Entity\Forum                        $forum
  * @param  \CCDNForum\ForumBundle\Entity\Topic                        $topic
  * @return \CCDNForum\ForumBundle\Component\Crumbs\Factory\CrumbTrail
  */
 public function addUserTopicShow(Forum $forum, Topic $topic)
 {
     return $this->addUserBoardShow($forum, $topic->getBoard())->add($topic->getTitle(), array('route' => 'ccdn_forum_user_topic_show', 'params' => array('forumName' => $forum->getName(), 'topicId' => $topic->getId())));
 }
 /**
  *
  * @access protected
  * @param  \CCDNForum\ForumBundle\Entity\Topic      $topic
  * @return null|\CCDNForum\ForumBundle\Entity\Board
  */
 private function extractBoardFromTopic(Topic $topic)
 {
     if ($topic) {
         if ($topic->getId()) {
             return $topic->getBoard();
         }
     }
     return null;
 }
 /**
  *
  * @access protected
  * @param  string                                             $forumName
  * @param  \CCDNForum\ForumBundle\Entity\Topic                $topic
  * @param  \CCDNForum\ForumBundle\Entity\Post                 $post
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 protected function redirectResponseForTopicOnPageFromPost($forumName, Topic $topic, Post $post)
 {
     //$page = $this->getTopicModel()->getPageForPostOnTopic($topic, $topic->getLastPost()); // Page of the last post.
     $response = $this->redirectResponse($this->path('ccdn_forum_user_topic_show', array('forumName' => $forumName, 'topicId' => $topic->getId())));
     return $response;
 }