Return empty list if there is no more edition instead of Error 404

This commit is contained in:
Kouril42
2023-02-28 16:42:31 +01:00
parent 33677c9232
commit 68135b4567
2 changed files with 10 additions and 39 deletions
+9 -13
View File
@@ -182,19 +182,15 @@ class MapApiController extends AbstractController
#[Route('/api/map/get_all_editions')]
public function getEditions(EditionRepository $rep): JsonResponse
{
$edits = $rep->getAllEditions();
if (sizeof($edits)<1) { throw new NotFoundHttpException('Warning: There is no more edition to check.'); }
else {
$listEdits = array();
foreach ($edits as $edit){
$listEdits[] = array(
'id' => $edit->getId(),
'mode' => $edit->getMode(),
'placeNames' => $edit->getEditedPlace()->getJoinedNames(),
'placeId' => $edit->getEditedPlace()->getId(),
'editorValue' => $edit->getValue()
);
}
$listEdits = array();
foreach ($rep->getAllEditions() as $edit){
$listEdits[] = array(
'id' => $edit->getId(),
'mode' => $edit->getMode(),
'placeNames' => $edit->getEditedPlace()->getJoinedNames(),
'placeId' => $edit->getEditedPlace()->getId(),
'editorValue' => $edit->getValue()
);
}
return $this->json($listEdits);
}