find_place_by_name returns a list of places with name NAME if many occurence of NAME are found

This commit is contained in:
Kouril42 2023-02-19 11:55:13 +01:00
parent 9f185ce8a2
commit a57adb9883

View File

@ -104,17 +104,16 @@ class MapApiController extends AbstractController
{
$places = $rep->findPlaceByName($name);
if (sizeof($places)==0){ throw new NotFoundHttpException('Error: \''.$name.'\' doesn\'t correspond to any placeName.'); }
elseif (sizeof($places)>1) { throw new UnprocessableEntityHttpException('Error: \''.$name.'\' refers to more than one place ; the API can\'t decide which one should be provided.'); }
else {
$place = $places[0];
$all = array();
foreach ($places as $place){
$floorsId = array();
foreach ($place->getFloors() as $floor) {
$floorsId[] = $floor->getId();
}
return $this->json([
'idRoom' => $place->getId(),
'idFloors' => $floorsId
]);
$all[] = array('idRoom' => $place->getId(), 'idFloors' => $floorsId);
}
return $this->json($all);
}
}