mirror of
https://gitlab.aliens-lyon.fr/encartes/backend.git
synced 2026-03-17 22:51:04 +01:00
find_place_by_name returns a list of places with name NAME if many occurence of NAME are found
This commit is contained in:
parent
9f185ce8a2
commit
a57adb9883
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user