/**
  * @Route("/{slug}/whitelist", name="server_whitelist", options={"expose": true})
  * @ParamConverter("server", class="StreamPerkServerBundle:Server")
  * @Security("is_granted('SHOW', server)")
  */
 public function whitelistAction(Request $request, Server $server)
 {
     if ($server->getWhitelisted() === false) {
         return $this->redirectToRoute('server_view', ['slug' => $server->getSlug()]);
     }
     $serverUserManager = $this->get('streamperk.server_user_manager');
     $newUser = false;
     $serverUser = $serverUserManager->findOneBy(['server' => $server, 'user' => $this->getUser()]);
     if ($serverUser instanceof ServerUser === false) {
         $serverUser = $serverUserManager->createManagedEntity()->setServer($server)->setUser($this->getUser());
         $newUser = true;
     }
     $serverQuestionAnswerManager = $this->get('streamperk.server_question_answer_manager');
     foreach ($server->getQuestions() as $question) {
         $answer = null;
         if ($newUser === false) {
             $answer = $serverQuestionAnswerManager->findOneBy(['serverUser' => $serverUser, 'serverQuestion' => $question]);
         }
         if ($answer instanceof ServerQuestionAnswer === false) {
             $answer = $serverQuestionAnswerManager->createManagedEntity()->setServerQuestion($question)->setServerUser($serverUser);
             $serverUser->addAnswer($answer);
         }
     }
     $whitelistForm = $this->createForm(ServerWhitelistType::class, $serverUser);
     $whitelistForm->handleRequest($request);
     if ($whitelistForm->isValid()) {
         $serverUser->setApproved(false);
         $serverUserManager->persist($serverUser);
         $serverUserManager->flush();
     }
     return $this->render('StreamPerkServerBundle:User:whitelist.html.twig', ['server' => $server, 'serverUser' => $serverUser, 'whitelistForm' => $whitelistForm->createView()] + $this->getDefaultViewParameters());
 }