Ejemplo n.º 1
0
 /**
  *
  * @access protected
  * @param \Map2u\ForumBundle\Entity\Board $board
  */
 protected function updateBoardStats(Board $board)
 {
     if ($board) {
         if ($board->getId()) {
             $stats = $this->topicModel->getTopicAndPostCountForBoardById($board->getId());
             // set the board topic / post count
             $board->setCachedTopicCount($stats['topicCount']);
             $board->setCachedPostCount($stats['postCount']);
             $lastTopic = $this->topicModel->findLastTopicForBoardByIdWithLastPost($board->getId());
             // set last_post for board
             if ($lastTopic) {
                 $board->setLastPost($lastTopic->getLastPost() ?: null);
             } else {
                 $board->setLastPost(null);
             }
             $this->boardModel->updateBoard($board);
         }
     }
 }