mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-03-06 20:54:20 +01:00
WIP
This commit is contained in:
@@ -87,6 +87,7 @@ final class BackofficeController extends AbstractController
|
||||
}
|
||||
|
||||
#[Route('/backoffice/{seasonCode}/{quiz}', name: 'app_backoffice_quiz')]
|
||||
#[IsGranted(SeasonVoter::EDIT, subject: 'season')]
|
||||
public function quiz(Season $season, Quiz $quiz): Response
|
||||
{
|
||||
return $this->render('backoffice/quiz.html.twig', [
|
||||
@@ -98,7 +99,7 @@ final class BackofficeController extends AbstractController
|
||||
|
||||
#[Route('/backoffice/{seasonCode}/{quiz}/enable', name: 'app_backoffice_enable')]
|
||||
#[IsGranted(SeasonVoter::EDIT, subject: 'season')]
|
||||
public function enableQuiz(Season $season, Quiz $quiz, EntityManagerInterface $em): Response
|
||||
public function enableQuiz(Season $season, ?Quiz $quiz, EntityManagerInterface $em): Response
|
||||
{
|
||||
$season->setActiveQuiz($quiz);
|
||||
$em->flush();
|
||||
@@ -107,6 +108,7 @@ final class BackofficeController extends AbstractController
|
||||
}
|
||||
|
||||
#[Route('/backoffice/{seasonCode}/add_candidate', name: 'app_backoffice_add_candidates', priority: 10)]
|
||||
#[IsGranted(SeasonVoter::EDIT, subject: 'season')]
|
||||
public function addCandidates(Season $season, Request $request, EntityManagerInterface $em): Response
|
||||
{
|
||||
$form = $this->createForm(AddCandidatesFormType::class);
|
||||
@@ -114,9 +116,10 @@ final class BackofficeController extends AbstractController
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$candidates = $form->get('candidates')->getData();
|
||||
foreach (explode("\r\n", $candidates) as $candidate) {
|
||||
foreach (explode("\r\n", (string) $candidates) as $candidate) {
|
||||
$season->addCandidate(new Candidate($candidate));
|
||||
}
|
||||
|
||||
$em->flush();
|
||||
|
||||
return $this->redirectToRoute('app_backoffice_season', ['seasonCode' => $season->getSeasonCode()]);
|
||||
@@ -126,6 +129,7 @@ final class BackofficeController extends AbstractController
|
||||
}
|
||||
|
||||
#[Route('/backoffice/{seasonCode}/add', name: 'app_backoffice_quiz_add', priority: 10)]
|
||||
#[IsGranted(SeasonVoter::EDIT, subject: 'season')]
|
||||
public function addQuiz(Request $request, Season $season, QuizSpreadsheetService $quizSpreadsheet, EntityManagerInterface $em): Response
|
||||
{
|
||||
$quiz = new Quiz();
|
||||
|
||||
54
src/Controller/EliminationController.php
Normal file
54
src/Controller/EliminationController.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\Candidate;
|
||||
use App\Entity\Season;
|
||||
use App\Enum\FlashType;
|
||||
use App\Helpers\Base64;
|
||||
use App\Repository\CandidateRepository;
|
||||
use App\Security\Voter\SeasonVoter;
|
||||
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
use function Symfony\Component\Translation\t;
|
||||
|
||||
#[AsController]
|
||||
#[IsGranted('ROLE_USER')]
|
||||
final class EliminationController extends AbstractController
|
||||
{
|
||||
public function __construct(private readonly TranslatorInterface $translator) {}
|
||||
|
||||
#[Route('/elimination/{seasonCode}', name: 'app_elimination')]
|
||||
#[IsGranted(SeasonVoter::ELIMINATION, 'season')]
|
||||
public function index(#[MapEntity] Season $season): Response
|
||||
{
|
||||
return $this->render('elimination/index.html.twig', [
|
||||
'controller_name' => 'EliminationController',
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/elimination/{seasonCode}/{candidateHash}', name: 'app_elimination_cadidate')]
|
||||
#[IsGranted(SeasonVoter::ELIMINATION, 'season')]
|
||||
public function candidateScreen(Season $season, string $candidateHash, CandidateRepository $candidateRepository): Response
|
||||
{
|
||||
$candidate = $candidateRepository->getCandidateByHash($season, $candidateHash);
|
||||
if (!$candidate instanceof Candidate) {
|
||||
$this->addFlash(FlashType::Warning,
|
||||
t('Cound not find candidate with name %name%', ['%name%' => Base64::base64UrlDecode($candidateHash)])->trans($this->translator)
|
||||
);
|
||||
throw new \InvalidArgumentException('Candidate not found');
|
||||
}
|
||||
|
||||
return $this->render('elimination/candidate.html.twig', [
|
||||
'season' => $season,
|
||||
'candidate' => $candidate,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -4,17 +4,21 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\Quiz;
|
||||
use App\Entity\Season;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
final class PrepareEliminationController extends AbstractController
|
||||
{
|
||||
#[Route('/backoffice/elimination/prepare', name: 'app_prepare_elimination')]
|
||||
public function index(): Response
|
||||
#[Route('/backoffice/elimination/{seasonCode}/{quiz}/prepare', name: 'app_prepare_elimination')]
|
||||
public function index(Season $season, Quiz $quiz): Response
|
||||
{
|
||||
return $this->render('prepare_elimination/index.html.twig', [
|
||||
'controller_name' => 'PrepareEliminationController',
|
||||
'season' => $season,
|
||||
'quiz' => $quiz,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user