Add B and S name for get_floor and return empty list if find_place_by_name doesn't find anything

This commit is contained in:
Kouril42
2023-02-28 16:38:18 +01:00
parent 33d15d4400
commit 33677c9232
2 changed files with 30 additions and 22 deletions
+18 -17
View File
@@ -113,8 +113,12 @@ class MapApiController extends AbstractController
return $this->json("Error on represantation attribute");
}
$building = $floor->getBuilding();
return $this->json(['idSite' => $building->getSite()->getId(),
return $this->json([
'name' => $floor->getName(),
'idSite' => $building->getSite()->getId(),
'nameSite' => $building->getSite()->getName(),
'idBuilding' => $building->getId(),
'nameBuilding' => $building->getName(),
'places' => $jsonPlaces
]);
}
@@ -141,24 +145,21 @@ class MapApiController extends AbstractController
#[Route('/api/map/find_place_by_name/{name}')]
public function find_place_by_name(PlaceRepository $rep, string $name): JsonResponse
{
$places = $rep->findPlaceByName($name);
if (sizeof($places)==0){ throw new NotFoundHttpException('Error: \''.$name.'\' doesn\'t correspond to any placeName.'); }
else {
$all = array();
foreach ($places as $place){
$floorsId = array();
foreach ($place->getFloors() as $floor) {
$floorsId[] = $floor->getId();
}
$building = $place->getFloors()[0]->getBuilding();
$all[] = array('idRoom' => $place->getId(),
'idSite' => $building->getSite()->getId(),
'idBuilding' => $building->getId(),
'idFloors' => $floorsId
);
$result = array();
foreach ($rep->findPlaceByName($name) as $place){
$floorsId = array();
foreach ($place->getFloors() as $floor) {
$floorsId[] = $floor->getId();
}
return $this->json($all);
$building = $place->getFloors()[0]->getBuilding();
$result[] = array(
'idRoom' => $place->getId(),
'idSite' => $building->getSite()->getId(),
'idBuilding' => $building->getId(),
'idFloors' => $floorsId
);
}
return $this->json($result);
}