From 5d66658842563f914c796ad46d465cb84e239d84 Mon Sep 17 00:00:00 2001 From: Kouril42 Date: Fri, 17 Feb 2023 17:21:44 +0100 Subject: [PATCH] Add get_all_floors --- src/Controller/MapApiController.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/Controller/MapApiController.php b/src/Controller/MapApiController.php index fa1f51f..efb43bf 100644 --- a/src/Controller/MapApiController.php +++ b/src/Controller/MapApiController.php @@ -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 {