From 64004b2ed8e2dbdff10f8e2a2aba1fbdb14275e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Skowro=C5=84ski?= Date: Sun, 7 Jan 2024 17:23:28 +0100 Subject: [PATCH] Use dedicated repository method to fetch single mod list --- src/Api/Controller/GetModListByNameAction.php | 4 +--- src/Controller/ModListPublic/SelectAction.php | 2 +- src/Repository/ModList/ModListRepository.php | 5 +++++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Api/Controller/GetModListByNameAction.php b/src/Api/Controller/GetModListByNameAction.php index bd98cd12..63d7d8d5 100644 --- a/src/Api/Controller/GetModListByNameAction.php +++ b/src/Api/Controller/GetModListByNameAction.php @@ -17,9 +17,7 @@ public function __construct( public function __invoke(string $name): ?ModList { - $modList = $this->modListRepository->findOneBy([ - 'name' => $name, - ]); + $modList = $this->modListRepository->findOneByName($name); if (!$modList) { throw new NotFoundHttpException('Not Found'); diff --git a/src/Controller/ModListPublic/SelectAction.php b/src/Controller/ModListPublic/SelectAction.php index e627cdef..346a0393 100644 --- a/src/Controller/ModListPublic/SelectAction.php +++ b/src/Controller/ModListPublic/SelectAction.php @@ -37,7 +37,7 @@ public function __invoke(): Response $nextMissionModList = null; if ($nextMission) { - $nextMissionModList = $this->modListRepository->findOneBy(['name' => $nextMission->getModlist()]); + $nextMissionModList = $this->modListRepository->findOneByName($nextMission->getModlist()); } return $this->render('mod_list_public/select.html.twig', [ diff --git a/src/Repository/ModList/ModListRepository.php b/src/Repository/ModList/ModListRepository.php index 5e5b6179..314e98be 100644 --- a/src/Repository/ModList/ModListRepository.php +++ b/src/Repository/ModList/ModListRepository.php @@ -20,4 +20,9 @@ public function __construct(ManagerRegistry $registry) { parent::__construct($registry, ModList::class); } + + public function findOneByName(string $name): ?ModList + { + return $this->findOneBy(['name' => $name]); + } }