mirror of
https://gitlab.aliens-lyon.fr/encartes/backend.git
synced 2026-09-11 16:50:46 +02:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user