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

27
API.md
View File

@ -173,10 +173,9 @@ __Each edition is a dict :__
'editorValue': string // the value to add or remove 'editorValue': string // the value to add or remove
} }
``` ```
__Errors :__
- If there is no pending edition : Return Error 404 "NotFoundHttpError" > It's a Warning that is not fatal (but I didn't manage to raise a warning with symfony so it's still an error)
__Notes :__ __Notes :__
- If there is no pending edition : Return Empty list
- The strings in mode are transparent to the API so the given names are only an advice. The only rules is to set adequaly create_edition and the treatment of editions. - The strings in mode are transparent to the API so the given names are only an advice. The only rules is to set adequaly create_edition and the treatment of editions.
--------------------- ---------------------
@ -205,30 +204,6 @@ __Errors :__
- If _ID_ doesn't correspond to any registered edition : Return Error 404 "NotFoundHttpError". - If _ID_ doesn't correspond to any registered edition : Return Error 404 "NotFoundHttpError".
- If _ID_ has many occurence in the EditionRepository : Return Error 500 > The Database is corrupted. - If _ID_ has many occurence in the EditionRepository : Return Error 500 > The Database is corrupted.
---------------------
### /api/map/get_site_name/ID
> Return the name of a site ID
__Errors :__
- If _ID_ doesn't correspond to any registered site : Return Error 404 "NotFoundHttpError".
- If _ID_ has many occurence in the EditionRepository : Return Error 500 > The Database is corrupted.
---------------------
### /api/map/get_building_name/ID
> Return the name of a building ID
__Errors :__
- If _ID_ doesn't correspond to any registered building : Return Error 404 "NotFoundHttpError".
- If _ID_ has many occurence in the EditionRepository : Return Error 500 > The Database is corrupted.
---------------------
### /api/map/get_floor_name/ID
> Return the name of a floor ID
__Errors :__
- If _ID_ doesn't correspond to any registered floor : Return Error 404 "NotFoundHttpError".
- If _ID_ has many occurence in the EditionRepository : Return Error 500 > The Database is corrupted.
--------------------- ---------------------
### /api/map/del_place_name/PLACEID/NAME ### /api/map/del_place_name/PLACEID/NAME
> Remove _NAME_ from the place _PLACEID_. > Remove _NAME_ from the place _PLACEID_.

View File

@ -182,19 +182,15 @@ class MapApiController extends AbstractController
#[Route('/api/map/get_all_editions')] #[Route('/api/map/get_all_editions')]
public function getEditions(EditionRepository $rep): JsonResponse public function getEditions(EditionRepository $rep): JsonResponse
{ {
$edits = $rep->getAllEditions(); $listEdits = array();
if (sizeof($edits)<1) { throw new NotFoundHttpException('Warning: There is no more edition to check.'); } foreach ($rep->getAllEditions() as $edit){
else { $listEdits[] = array(
$listEdits = array(); 'id' => $edit->getId(),
foreach ($edits as $edit){ 'mode' => $edit->getMode(),
$listEdits[] = array( 'placeNames' => $edit->getEditedPlace()->getJoinedNames(),
'id' => $edit->getId(), 'placeId' => $edit->getEditedPlace()->getId(),
'mode' => $edit->getMode(), 'editorValue' => $edit->getValue()
'placeNames' => $edit->getEditedPlace()->getJoinedNames(), );
'placeId' => $edit->getEditedPlace()->getId(),
'editorValue' => $edit->getValue()
);
}
} }
return $this->json($listEdits); return $this->json($listEdits);
} }