createForm(EliminationEnterNameType::class); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $name = $form->get('name')->getData(); return $this->redirectToRoute('app_elimination_candidate', ['elimination' => $elimination->getId(), 'candidateHash' => Base64::base64UrlEncode($name)]); } return $this->render('quiz/elimination/index.html.twig', [ 'form' => $form, 'controller_name' => 'EliminationController', ]); } #[Route('/elimination/{elimination}/{candidateHash}', name: 'app_elimination_candidate')] #[IsGranted(SeasonVoter::ELIMINATION, 'elimination')] public function candidateScreen(Elimination $elimination, string $candidateHash, CandidateRepository $candidateRepository): Response { $candidate = $candidateRepository->getCandidateByHash($elimination->getQuiz()->getSeason(), $candidateHash); if (!$candidate instanceof Candidate) { $this->addFlash(FlashType::Warning, t('Cound not find candidate with name %name%', ['%name%' => Base64::base64UrlDecode($candidateHash)])->trans($this->translator), ); return $this->redirectToRoute('app_elimination', ['elimination' => $elimination->getId()]); } $screenColour = $elimination->getScreenColour($candidate->getName()); if (null === $screenColour) { $this->addFlash(FlashType::Warning, $this->translator->trans('Cound not find candidate with name %name% in elimination.', ['%name%' => $candidate->getName()])); return $this->redirectToRoute('app_elimination', ['elimination' => $elimination->getId()]); } return $this->render('quiz/elimination/candidate.html.twig', [ 'candidate' => $candidate, 'colour' => $screenColour, ]); } }