Skip to content

Commit

Permalink
Use dedicated repository method to fetch single mod list (#308)
Browse files Browse the repository at this point in the history
This will:
- title
  • Loading branch information
jskowronski39 authored Jan 8, 2024
2 parents 00dad38 + 64004b2 commit 9ce7f74
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/Api/Controller/GetModListByNameAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/ModListPublic/SelectAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', [
Expand Down
5 changes: 5 additions & 0 deletions src/Repository/ModList/ModListRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}

0 comments on commit 9ce7f74

Please sign in to comment.