mirror of
https://gitlab.aliens-lyon.fr/encartes/backend.git
synced 2026-09-11 16:50:46 +02:00
Sauvegarde avant le carnage
This commit is contained in:
@@ -11,29 +11,44 @@ use App\Repository\RoomRepository;
|
||||
class MapApiController extends AbstractController
|
||||
{
|
||||
#[Route('/map/api')]
|
||||
public function test(SiteRepository $srep): JsonResponse
|
||||
public function test(SiteRepository $rep): JsonResponse
|
||||
{
|
||||
|
||||
return $this->json([
|
||||
'message' => 'Welcome to your new controller!',
|
||||
'path' => 'src/Controller/MapApiController.php',
|
||||
'sites' => $srep->allSites()[0]->getZeroLatitude()
|
||||
'sites' => $rep->allSites()[0]->getZeroLatitude()
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/map/api/get_floor')]
|
||||
public function get_floor(FloorRepository $srep, int $id): JsonResponse
|
||||
public function get_floor(FloorRepository $rep, int $id): JsonResponse
|
||||
{
|
||||
return $rep->get_floor(id);
|
||||
return $this->json([
|
||||
'message' => 'Welcome to your new controller!',
|
||||
'path' => 'src/Controller/MapApiController.php',
|
||||
'sites' => $srep->allSites()[0]->getZeroLatitude()
|
||||
]);
|
||||
$floor = $rep->findFloorById($id);
|
||||
$corridors = $floor->getCorridors();
|
||||
$rooms = array();
|
||||
foreach ($corridors as $cor){
|
||||
foreach ($cor->getConnectedPlaces() as $place) {
|
||||
if (($place instanceof Room) and !($rooms->contains($place))) {
|
||||
$rooms[] = $place;
|
||||
}
|
||||
}
|
||||
}
|
||||
$jsonCorridors = array();
|
||||
$jsonRooms = array();
|
||||
foreach ($corridors as $cor){
|
||||
$jsonCorridors[] = $this->json([
|
||||
'id' => $cor->getId(),
|
||||
'name' => $cor->getName(),
|
||||
'type' => $cor->getType()
|
||||
//'polygon' => $cor->getPolyhedronRepresentation()
|
||||
]);
|
||||
}
|
||||
return array($jsonCorridors, $jsonRooms);
|
||||
}
|
||||
|
||||
#[Route('/map/api/find_room_by_name')]
|
||||
public function find_room_by_name(RoomRepository $srep, string $name): JsonResponse
|
||||
public function find_room_by_name(RoomRepository $rep, string $name): JsonResponse
|
||||
{
|
||||
$rooms = $rep->findRoomByName($name);
|
||||
if (sizeof($rooms)!=1) {
|
||||
@@ -53,7 +68,7 @@ class MapApiController extends AbstractController
|
||||
|
||||
|
||||
#[Route('/map/api/show_room_info')]
|
||||
public function index(RoomRepository $srep, int $id): JsonResponse
|
||||
public function index(RoomRepository $rep, int $id): JsonResponse
|
||||
{
|
||||
$rooms = $rep->findRoomById($id);
|
||||
if (sizeof($rooms)!=1) {
|
||||
@@ -62,12 +77,70 @@ class MapApiController extends AbstractController
|
||||
else {
|
||||
return $this->json([
|
||||
'idRoom' => $rooms[0]->getId(),
|
||||
'names' => $rooms[0]->getNames(),
|
||||
'users' => $rooms[0]->getUsers()
|
||||
'names' => $rooms[0]->getName(),
|
||||
'users' => $rooms[0]->getUser()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// #[Route('/map/api/get_all_propal_edit')]
|
||||
// public function index(EditRepository $rep): JsonResponse
|
||||
// {
|
||||
// $edits = $rep->getAllEdit($id);
|
||||
// if (sizeof($rooms)<1) {
|
||||
// return null;
|
||||
// }
|
||||
// else {
|
||||
// $listEdits = []
|
||||
// for i
|
||||
// return $this->json([
|
||||
// 'idRoom' => $rooms[0]->getId(),
|
||||
// 'names' => $rooms[0]->getName(),
|
||||
// 'users' => $rooms[0]->getUser()
|
||||
// ]);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
#[Route('/map/api/del_room_name')]
|
||||
public function delRoomName(RoomRepository $rep, int $id, string $value): bool
|
||||
{
|
||||
$rooms = $rep->findRoomById($id);
|
||||
if (sizeof($rooms)!=1) { return null; }
|
||||
else {
|
||||
$rooms[0]->removeName($value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#[Route('/map/api/add_room_name')]
|
||||
public function addRoomName(RoomRepository $rep, int $id, string $value): bool
|
||||
{
|
||||
$rooms = $rep->findRoomById($id);
|
||||
if (sizeof($rooms)!=1) { return null; }
|
||||
else {
|
||||
$rooms[0]->addName($value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#[Route('/map/api/del_prof_room_name')]
|
||||
public function delProfRoomName(RoomRepository $rep, int $id, string $value): bool
|
||||
{
|
||||
$rooms = $rep->findRoomById($id);
|
||||
if (sizeof($rooms)!=1) { return null; }
|
||||
else {
|
||||
$rooms[0]->delUser($value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#[Route('/map/api/add_prof_room_name')]
|
||||
public function addProfRoomName(RoomRepository $rep, int $id, string $value): bool
|
||||
{
|
||||
$rooms = $rep->findRoomById($id);
|
||||
if (sizeof($rooms)!=1) { return null; }
|
||||
else {
|
||||
$rooms[0]->addUser($value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user