/**
  *
  * @access protected
  * @param \CCDNForum\ForumBundle\Entity\Board $board
  */
 protected function onSuccess(Board $board)
 {
     $this->dispatcher->dispatch(ForumEvents::ADMIN_BOARD_DELETE_SUCCESS, new AdminBoardEvent($this->request, $board));
     if (!$this->form->get('confirm_subordinates')->getData()) {
         $topics = new ArrayCollection($board->getTopics()->toArray());
         $this->boardModel->reassignTopicsToBoard($topics, null)->flush();
     }
     $this->boardModel->deleteBoard($board);
     $this->dispatcher->dispatch(ForumEvents::ADMIN_BOARD_DELETE_COMPLETE, new AdminBoardEvent($this->request, $board));
 }
 /**
  *
  * @access public
  * @return \Symfony\Component\Form\Form
  */
 public function getForm()
 {
     if (null == $this->form) {
         // Store the old board before proceeding, as we will need it to update its stats
         // as it will be a topic down in its count at least, posts perhaps even more so.
         $this->oldBoard = $this->topic->getBoard();
         // Boards are pre-filtered for proper rights managements, moderators may move Topics,
         // but some boards may only be accessible by admins, so moderators should not see them.
         $filteredBoards = $this->boardModel->findAllBoardsForForumById($this->forum->getId());
         $options = array('boards' => $filteredBoards);
         $this->dispatcher->dispatch(ForumEvents::MODERATOR_TOPIC_CHANGE_BOARD_INITIALISE, new ModeratorTopicEvent($this->request, $this->topic));
         $this->form = $this->factory->create($this->formTopicChangeBoardType, $this->topic, $options);
     }
     return $this->form;
 }
 /**
  *
  * @access protected
  * @param \CCDNForum\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 public
  * @return \Symfony\Component\Form\Form
  */
 public function getForm()
 {
     if (null == $this->form) {
         if (!is_object($this->board) || !$this->board instanceof Board) {
             throw new \Exception('Board must be specified to be create a Topic in TopicCreateFormHandler');
         }
         $filteredBoards = $this->boardModel->findAllBoardsForForumById($this->forum->getId());
         $topicOptions = array('boards' => $filteredBoards, 'auto_initialize' => false);
         $topic = $this->topicModel->createTopic();
         $topic->setBoard($this->board);
         $post = $this->postModel->createPost();
         $post->setTopic($topic);
         $post->setCreatedBy($this->user);
         $this->dispatcher->dispatch(ForumEvents::USER_TOPIC_CREATE_INITIALISE, new UserTopicEvent($this->request, $post->getTopic()));
         $this->form = $this->factory->create($this->formPostType, $post);
         $this->form->add($this->factory->create($this->formTopicType, $topic, $topicOptions));
     }
     return $this->form;
 }
 /**
  *
  * @access protected
  * @param \CCDNForum\ForumBundle\Entity\Board $board
  */
 protected function onSuccess(Board $board)
 {
     $this->dispatcher->dispatch(ForumEvents::ADMIN_BOARD_EDIT_SUCCESS, new AdminBoardEvent($this->request, $board));
     $this->boardModel->updateBoard($board);
     $this->dispatcher->dispatch(ForumEvents::ADMIN_BOARD_EDIT_COMPLETE, new AdminBoardEvent($this->request, $board));
 }