/** * * @access protected * @param \Map2u\ForumBundle\Entity\Post $post */ protected function onSuccess(Post $post) { $post->setCreatedDate(new \DateTime()); $post->setCreatedBy($this->user); $post->setDeleted(false); $topic = $post->getTopic(); $topic->setCachedViewCount(0); $topic->setCachedReplyCount(0); $topic->setClosed(false); $topic->setDeleted(false); $topic->setSticky(false); $this->dispatcher->dispatch(ForumEvents::USER_TOPIC_CREATE_SUCCESS, new UserTopicEvent($this->request, $topic)); $this->postModel->savePost($post); $topic->setFirstPost($post); $topic->setLastPost($post); $this->topicModel->saveTopic($topic); $this->dispatcher->dispatch(ForumEvents::USER_TOPIC_CREATE_COMPLETE, new UserTopicEvent($this->request, $topic, $this->didAuthorSubscribe())); }
/** * * @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); } } }
/** * * @access protected * @param \Map2u\ForumBundle\Entity\Topic $topic */ protected function onSuccess(Topic $topic) { $this->dispatcher->dispatch(ForumEvents::MODERATOR_TOPIC_CHANGE_BOARD_SUCCESS, new ModeratorTopicEvent($this->request, $topic)); $this->topicModel->updateTopic($topic); $this->dispatcher->dispatch(ForumEvents::MODERATOR_TOPIC_CHANGE_BOARD_COMPLETE, new ModeratorTopicMoveEvent($this->request, $this->oldBoard, $topic->getBoard(), $topic)); }
/** * * @access protected * @param \Map2u\ForumBundle\Entity\Topic $topic */ protected function onSuccess(Topic $topic) { $this->dispatcher->dispatch(ForumEvents::MODERATOR_TOPIC_SOFT_DELETE_SUCCESS, new ModeratorTopicEvent($this->request, $this->topic)); $this->topicModel->softDelete($topic, $this->user); $this->dispatcher->dispatch(ForumEvents::MODERATOR_TOPIC_SOFT_DELETE_COMPLETE, new ModeratorTopicEvent($this->request, $topic)); }