diff --git a/src/Controller/MapApiController.php b/src/Controller/MapApiController.php index bd91729..e97f79b 100644 --- a/src/Controller/MapApiController.php +++ b/src/Controller/MapApiController.php @@ -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]; - $floorsId = array(); - foreach ($place->getFloors() as $floor) { - $floorsId[] = $floor->getId(); + $all = array(); + foreach ($places as $place){ + $floorsId = array(); + foreach ($place->getFloors() as $floor) { + $floorsId[] = $floor->getId(); + } + $all[] = array('idRoom' => $place->getId(), 'idFloors' => $floorsId); } - return $this->json([ - 'idRoom' => $place->getId(), - 'idFloors' => $floorsId - ]); + return $this->json($all); } }