Debug API

This commit is contained in:
Kouril42 2023-02-19 12:44:44 +01:00
parent c6222386a0
commit 88ec6295fc

View File

@ -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(),