public function newAction($boardSlug = null)
 {
     $board = $this->getBoard();
     $user = $this->getUser();
     $this->throwAccessDeniedIfLoggedOut();
     $this->throwAccessDeniedIfPermission('canCreateTopic', $user, $board);
     $request = $this->get('request');
     // List of existing topics with the same slug or title
     $existingTopics = array();
     $topic = new Topic();
     $form = $this->createForm(new CreateTopicType(), $topic);
     if ($request->getMethod() === 'POST') {
         $form->bind($request);
         $boardId = $request->request->get('board_id');
         if ($board === null && $boardId === '') {
             $form->addError(new FormError($this->get('translator')->trans('Board.selected.not.valid')));
         } else {
             if ($boardId !== null) {
                 $board = $this->get('teapotio.forum.board')->getById($boardId);
             }
         }
         if ($form->isValid() === true) {
             try {
                 $topic->setBoard($board);
                 $this->get('teapotio.forum.topic')->save($topic);
                 $message = new Message();
                 $message->setBody($form['body']->getData());
                 $message->setTopic($topic);
                 $message->setTopicBody(true);
                 $this->get('teapotio.forum.message')->save($message);
                 return $this->redirect($this->get('teapotio.forum')->forumPath('ForumListMessagesByTopic', $topic));
             } catch (DuplicateTopicException $e) {
                 $form->addError(new FormError($this->get('translator')->trans('Topic.title.is.already.in.use')));
                 $existingTopics = $e->topics;
             }
         }
     }
     $infoNotices = array();
     if ($board !== null) {
         $infoNotices[] = $this->get('translator')->trans('Create.topic.in.notice', array('%board_name%' => $board->getTitle()));
         $title = $this->generateTitle('New.topic.in.%title%', array('%title%' => $board->getTitle()));
     } else {
         $title = $this->generateTitle('New.topic');
     }
     $params = array('form' => $form->createView(), 'current_board' => $board, 'page_title' => $title, 'info_notices' => $infoNotices, 'existing_topics' => $existingTopics);
     return $this->superRender('TeapotioForumBundle:page:topic/new.html.twig', $params);
 }