From 057bc778ed32beb2d41146aa69982135826862fa Mon Sep 17 00:00:00 2001 From: Marijn Doeve Date: Mon, 21 Apr 2025 18:03:54 +0200 Subject: [PATCH] Fixes --- .idea/php.xml | 2 +- src/Command/TestCommand.php | 34 -------------------------- src/Controller/QuizController.php | 8 +++--- src/Form/EnterNameType.php | 1 + src/Form/SelectSeasonType.php | 7 ++++-- src/Repository/QuizRepository.php | 2 -- src/Repository/UserRepository.php | 6 +---- src/Security/Voter/SeasonVoter.php | 1 + translations/messages+intl-icu.nl.yaml | 3 ++- 9 files changed, 14 insertions(+), 50 deletions(-) delete mode 100644 src/Command/TestCommand.php diff --git a/.idea/php.xml b/.idea/php.xml index 0e6eef6..2a59b68 100644 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -10,7 +10,7 @@ diff --git a/src/Command/TestCommand.php b/src/Command/TestCommand.php deleted file mode 100644 index b273334..0000000 --- a/src/Command/TestCommand.php +++ /dev/null @@ -1,34 +0,0 @@ -candidateRepository->getScores($this->quizRepository->find('1f00ff44-6f12-630e-9b87-67e78e97c05e'))); - - return Command::SUCCESS; - } -} diff --git a/src/Controller/QuizController.php b/src/Controller/QuizController.php index 4a721b4..b5882e5 100644 --- a/src/Controller/QuizController.php +++ b/src/Controller/QuizController.php @@ -29,14 +29,11 @@ use Symfony\Contracts\Translation\TranslatorInterface; #[AsController] final class QuizController extends AbstractController { - public const string SEASON_CODE_REGEX = '[A-Za-z\d]{5}'; private const string CANDIDATE_HASH_REGEX = '[\w\-=]+'; - public function __construct(private readonly TranslatorInterface $translator) - { - } + public function __construct(private readonly TranslatorInterface $translator) {} #[Route(path: '/', name: 'app_quiz_selectseason', methods: ['GET', 'POST'])] public function selectSeason(Request $request, SeasonRepository $seasonRepository): Response @@ -48,8 +45,9 @@ final class QuizController extends AbstractController $data = $form->getData(); $season_code = $data['season_code']; - if ($seasonRepository->findBy(['seasonCode' => $season_code]) === []) { + if ([] === $seasonRepository->findBy(['seasonCode' => $season_code])) { $this->addFlash(FlashType::Warning, $this->translator->trans('Invalid season code')); + return $this->redirectToRoute('app_quiz_selectseason'); } diff --git a/src/Form/EnterNameType.php b/src/Form/EnterNameType.php index f3c3373..840418f 100644 --- a/src/Form/EnterNameType.php +++ b/src/Form/EnterNameType.php @@ -9,6 +9,7 @@ use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Contracts\Translation\TranslatorInterface; +/** @extends AbstractType */ class EnterNameType extends AbstractType { public function __construct(private readonly TranslatorInterface $translator) {} diff --git a/src/Form/SelectSeasonType.php b/src/Form/SelectSeasonType.php index 0e96ea3..48db112 100644 --- a/src/Form/SelectSeasonType.php +++ b/src/Form/SelectSeasonType.php @@ -9,16 +9,19 @@ use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Validator\Constraints\Regex; +use Symfony\Contracts\Translation\TranslatorInterface; +/** @extends AbstractType */ class SelectSeasonType extends AbstractType { + public function __construct(private readonly TranslatorInterface $translator) {} + public function buildForm(FormBuilderInterface $builder, array $options): void { $builder ->add('season_code', TextType::class, - ['required' => true, 'constraints' => new Regex(pattern: "/^[A-Za-z\d]{5}$/")], + ['required' => true, 'constraints' => new Regex(pattern: "/^[A-Za-z\d]{5}$/"), 'label' => $this->translator->trans('Season Code')] ) -// ->add('submit', SubmitType::class, ['label' => 'Start quiz']) ; } diff --git a/src/Repository/QuizRepository.php b/src/Repository/QuizRepository.php index b9ffadb..8d0421b 100644 --- a/src/Repository/QuizRepository.php +++ b/src/Repository/QuizRepository.php @@ -17,6 +17,4 @@ class QuizRepository extends ServiceEntityRepository { parent::__construct($registry, Quiz::class); } - - public function quizReault(Quiz $quiz): array {} } diff --git a/src/Repository/UserRepository.php b/src/Repository/UserRepository.php index eb6d672..1d3deaf 100644 --- a/src/Repository/UserRepository.php +++ b/src/Repository/UserRepository.php @@ -10,11 +10,7 @@ use Doctrine\Persistence\ManagerRegistry; use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface; use Symfony\Component\Security\Core\User\PasswordUpgraderInterface; -/** - * @extends ServiceEntityRepository - * - * @implements PasswordUpgraderInterface - */ +/** @extends ServiceEntityRepository */ class UserRepository extends ServiceEntityRepository implements PasswordUpgraderInterface { public function __construct(ManagerRegistry $registry) diff --git a/src/Security/Voter/SeasonVoter.php b/src/Security/Voter/SeasonVoter.php index 8dcc00f..71f0f6e 100644 --- a/src/Security/Voter/SeasonVoter.php +++ b/src/Security/Voter/SeasonVoter.php @@ -9,6 +9,7 @@ use App\Entity\User; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authorization\Voter\Voter; +/** @extends Voter */ final class SeasonVoter extends Voter { public const string EDIT = 'SEASON_EDIT'; diff --git a/translations/messages+intl-icu.nl.yaml b/translations/messages+intl-icu.nl.yaml index 5379739..b8c4a9c 100644 --- a/translations/messages+intl-icu.nl.yaml +++ b/translations/messages+intl-icu.nl.yaml @@ -8,13 +8,14 @@ Corrections: Jokers 'Create an account': 'Maak een account aan' Email: E-mail 'Enter your name': 'Voor je naam in' +'Invalid season code': 'Ongeldige seizoenscode' 'Load Prepared Elimination': 'Laad voorbereide eliminatie' Manage: Beheren Name: Naam 'No active quiz': 'Geen actieve test' 'No results': 'Geen resultaten' 'Number of dropouts:': 'Aantal afvallers:' -Owner(s): Eigenar(en) +Owner(s): Eigena(a)r(en) Password: Wachtwoord 'Please Confirm your Email': messages 'Please sign in': 'Log in aub'