/**
  * @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());
 }
 /**
  * @Route("/{code}", name="server_data_formatted")
  * @ParamConverter("server", class="StreamPerkServerBundle:Server")
  */
 public function getAction(Server $server)
 {
     if ($this->get('madrak_io_extendable_configuration.configuration_service')->get('server.data.publish_formatted_whitelist') != true) {
         return new JsonResponse(['error' => self::DATA_PUBLISH_NOT_ENABLED]);
     }
     $users = [];
     foreach ($server->getUsers() as $user) {
         if ($this->get('streamperk.core.user_access_decision_manager')->isGranted($user->getUser(), AbstractVoter::SHOW, $server) === false) {
             continue;
         }
         if ($server->getRequiresApproval() === true && $user->getApproved() === false) {
             continue;
         }
         $users[] = $user;
     }
     return new Response($this->get('streamperk.server.server_type_chain')->getServerType($server->getServerType())->getFormattedData($users));
 }