protected function createTopic($board, $title) { $topic = new Topic(); $topic->setBoard($board); $topic->setTitle($title); $topic->setCachedViewCount(0); $topic->setCachedReplyCount(0); $topic->setSticky(false); $topic->setClosed(false); $topic->setDeleted(false); return $topic; }
/** * * @access protected * @param \CCDNForum\ForumBundle\Entity\Topic $topic */ protected function updateTopicStats(Topic $topic) { if ($topic->getId()) { // Get stats. $topicPostCount = $this->postModel->countPostsForTopicById($topic->getId()); $topicFirstPost = $this->postModel->getFirstPostForTopicById($topic->getId()); $topicLastPost = $this->postModel->getLastPostForTopicById($topic->getId()); // Set the board / topic last post. $topic->setCachedReplyCount($topicPostCount > 0 ? --$topicPostCount : 0); $topic->setFirstPost($topicFirstPost ?: null); $topic->setLastPost($topicLastPost ?: null); $this->topicModel->updateTopic($topic); } }