getUser(); \assert($user instanceof User); $seasons = $this->security->isGranted('ROLE_ADMIN') ? $this->seasonRepository->findAll() : $this->seasonRepository->getSeasonsForUser($user); return $this->render('backoffice/index.html.twig', [ 'seasons' => $seasons, ]); } #[Route('/backoffice/season/add', name: 'tvdt_backoffice_season_add', priority: 10)] public function addSeason(Request $request, EntityManagerInterface $em): Response { $season = new Season(); $form = $this->createForm(CreateSeasonFormType::class, $season); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $user = $this->getUser(); \assert($user instanceof User); $season->addOwner($user); $season->generateSeasonCode(); $em->persist($season); $em->flush(); return $this->redirectToRoute('tvdt_backoffice_season', ['seasonCode' => $season->seasonCode]); } return $this->render('backoffice/season_add.html.twig', ['form' => $form]); } #[Route('/backoffice/template', name: 'tvdt_backoffice_template', priority: 10)] public function getTemplate(QuizSpreadsheetService $excel): Response { $response = new StreamedResponse($excel->generateTemplate()); $response->headers->set('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); $response->headers->set('Content-Disposition', 'attachment; filename="template.xlsx"'); return $response; } }