Add get_all_floors

This commit is contained in:
Kouril42 2023-02-17 17:21:44 +01:00
parent 8f67569b41
commit 5d66658842

View File

@ -80,6 +80,25 @@ class MapApiController extends AbstractController
return $this->json($jsonPlaces->toArray());
}
#[Route('/api/map/get_all_floors/')]
public function get_all_floors(SiteRepository $sRep): JsonResponse
{
$sites = $sRep->allSites();
$response = array();
foreach ($sites as $s) {
$siteJSON = array();
foreach ($s->getBuildings() as $b) {
$buildJSON = array();
foreach ($b->getFloors() as $f){
$buildJSON[] = array(['name' => $f->getName(), 'id' => $f->getId()]);
}
$siteJSON[] = array(['name' => $b->getName(), 'id' => $b->getId(), 'floors' => $buildJSON]);
}
$response[] = array(['name' => $s->getName(), 'id' => $s->getId(), 'building' => $siteJSON]);
}
return $this->json($response);
}
#[Route('/api/map/find_place_by_name/{name}')]
public function find_place_by_name(PlaceRepository $rep, string $name): JsonResponse
{