diff --git a/src/Controller/MapApiController.php b/src/Controller/MapApiController.php index f4f4e75..e994549 100644 --- a/src/Controller/MapApiController.php +++ b/src/Controller/MapApiController.php @@ -58,7 +58,7 @@ class MapApiController extends AbstractController public function get_site_name(SiteRepository $rep, int $id): JsonResponse { $sites = $rep->findSiteById($id); - if (sizeof($sites) == 0) { throw new NotFoundHttpException('Error: '.$id.' doesn\'t correspond to any place.'); } + if (sizeof($sites) == 0) { throw new NotFoundHttpException('Error: '.$id.' doesn\'t correspond to any site.'); } elseif (sizeof($sites)>1) { throw new Exception('Internal Error: '.$id.' refers to more than one siteId ; the BDD is corrupted.'); } return $this->json($sites[0]->getName()); } @@ -67,7 +67,7 @@ class MapApiController extends AbstractController public function get_building_name(BuildingRepository $rep, int $id): JsonResponse { $buildings = $rep->findBuildingById($id); - if (sizeof($buildings) == 0) { throw new NotFoundHttpException('Error: '.$id.' doesn\'t correspond to any place.'); } + if (sizeof($buildings) == 0) { throw new NotFoundHttpException('Error: '.$id.' doesn\'t correspond to any building.'); } elseif (sizeof($buildings)>1) { throw new Exception('Internal Error: '.$id.' refers to more than one buildingId ; the BDD is corrupted.'); } return $this->json($buildings[0]->getName()); } @@ -76,7 +76,7 @@ class MapApiController extends AbstractController public function get_floor_name(FloorRepository $rep, int $id): JsonResponse { $floors = $rep->findFloorById($id); - if (sizeof($floors) == 0) { throw new NotFoundHttpException('Error: '.$id.' doesn\'t correspond to any place.'); } + if (sizeof($floors) == 0) { throw new NotFoundHttpException('Error: '.$id.' doesn\'t correspond to any floor.'); } elseif (sizeof($floors)>1) { throw new Exception('Internal Error: '.$id.' refers to more than one floorId ; the BDD is corrupted.'); } return $this->json($floors[0]->getName()); } @@ -106,8 +106,8 @@ class MapApiController extends AbstractController return $this->json(["Error on represantation attribute"]); } $building = $floor->getBuilding(); - return $this->json(['idSite' => $building->getId(), - 'idBuilding' => $building->getSite()->getId(), + return $this->json(['idSite' => $building->getSite()->getId(), + 'idBuilding' => $building->getId(), 'places' => $jsonPlaces ]); } @@ -143,7 +143,7 @@ class MapApiController extends AbstractController foreach ($place->getFloors() as $floor) { $floorsId[] = $floor->getId(); } - $building = $floorsId[0]->getBuilding(); + $building = $place->getFloors()[0]->getBuilding(); $all[] = array('idRoom' => $place->getId(), 'idSite' => $building->getSite()->getId(), 'idBuilding' => $building->getId(),