/**
  * Delete a topic from repository!
  *
  * @param Topic $topic The topic that is be deleted.
  *
  * @return void
  */
 public function topicConformDeleteAction(Topic $topic)
 {
     $this->authenticationService->assertModerationAuthorization($topic->getForum());
     foreach ($topic->getPosts() as $post) {
         $this->postRepository->remove($post);
     }
     $this->topicRepository->remove($topic);
     $this->controllerContext->getFlashMessageQueue()->enqueue(new FlashMessage(Localization::translate('Moderation_DeleteTopic_Success', 'Typo3Forum')));
     $this->clearCacheForCurrentPage();
     $this->redirect('show', 'Forum', NULL, array('forum' => $topic->getForum()));
 }
 /**
  * Deletes a topic and all posts contained in it.
  *
  * @param Topic $topic
  */
 public function deleteTopic(Topic $topic)
 {
     foreach ($topic->getPosts() as $post) {
         /** @var $post Post */
         $post->getAuthor()->decreasePostCount();
         $post->getAuthor()->decreasePoints((int) $this->settings['rankScore']['newPost']);
         $this->frontendUserRepository->update($post->getAuthor());
     }
     $forum = $topic->getForum();
     $forum->removeTopic($topic);
     $this->topicRepository->remove($topic);
     $this->persistenceManager->persistAll();
     $user = $this->getCurrentUser();
     if (!$user->isAnonymous()) {
         $user->decreaseTopicCount();
         if ($topic->getQuestion() == 1) {
             $user->decreaseQuestionCount();
         }
         $this->frontendUserRepository->update($user);
     }
 }