mirror of
https://gitlab.aliens-lyon.fr/encartes/backend.git
synced 2026-03-17 14:41:03 +01:00
Ajout d'un préfix d'API (pour le déploiement en vrai ^^)
This commit is contained in:
parent
ca239c1122
commit
5b74814963
2
.env
2
.env
@ -22,3 +22,5 @@ APP_SECRET=7f0dfc149d55b4ca2cf7bcc72c5ff7e1
|
||||
###> nelmio/cors-bundle ###
|
||||
CORS_ALLOW_ORIGIN='^.*$'
|
||||
###< nelmio/cors-bundle ###
|
||||
|
||||
API_PREFIX='/api'
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
controllers:
|
||||
prefix: '%api-prefix%'
|
||||
resource:
|
||||
path: ../src/Controller/
|
||||
namespace: App\Controller
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
# Put parameters here that don't need to change on each machine where the app is deployed
|
||||
# https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration
|
||||
parameters:
|
||||
api-prefix: '%env(API_PREFIX)%'
|
||||
|
||||
services:
|
||||
# default configuration for services in *this* file
|
||||
|
||||
@ -31,17 +31,8 @@ use App\Entity\ThreeDObjectFile;
|
||||
|
||||
class JsonReaderController extends AbstractController
|
||||
{
|
||||
#[Route('/api/debug/loadJson')]
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
return new Response(print_r($request,true));
|
||||
|
||||
$response = new Response();
|
||||
$response->setStatusCode(Response::HTTP_OK);
|
||||
return $response;
|
||||
}
|
||||
|
||||
#[Route('/api/debug/add_connection/{id1}/{id2}')]
|
||||
#[Route('/debug/add_connection/{id1}/{id2}')]
|
||||
public function add_connection(PlaceRepository $rep, int $id1, int $id2): JsonResponse
|
||||
{
|
||||
$place1 = $rep->findPlaceById($id1)[0];
|
||||
@ -51,7 +42,7 @@ class JsonReaderController extends AbstractController
|
||||
$rep->flush();
|
||||
return $this->json("Added");
|
||||
}
|
||||
#[Route('/api/debug/remove_connection/{id1}/{id2}')]
|
||||
#[Route('/debug/remove_connection/{id1}/{id2}')]
|
||||
public function remove_connection(PlaceRepository $rep, int $id1, int $id2): JsonResponse
|
||||
{
|
||||
$place1 = $rep->findPlaceById($id1)[0];
|
||||
@ -61,7 +52,7 @@ class JsonReaderController extends AbstractController
|
||||
$rep->flush();
|
||||
return $this->json("Removed");
|
||||
}
|
||||
#[Route('/api/debug/show_connection/{id1}')]
|
||||
#[Route('/debug/show_connection/{id1}')]
|
||||
public function show_connection(PlaceRepository $rep, int $id1): JsonResponse
|
||||
{
|
||||
$place1 = $rep->findPlaceById($id1)[0];
|
||||
@ -74,7 +65,7 @@ class JsonReaderController extends AbstractController
|
||||
}
|
||||
|
||||
|
||||
#[Route('/api/debug/initialData')]
|
||||
#[Route('/debug/initialData')]
|
||||
public function init(Request $request, SiteRepository $srep, BuildingRepository $brep, FloorRepository $frep, ManagerRegistry $mr): Response
|
||||
{
|
||||
//return new Response(print_r(json_decode($request->getContent()),true));
|
||||
@ -188,7 +179,7 @@ class JsonReaderController extends AbstractController
|
||||
|
||||
}
|
||||
|
||||
#[Route('/api/debug/dropAllDatabaseThereIsNoWayIGotTheNameOfThisPageWrong')]
|
||||
#[Route('/debug/dropAllDatabaseThereIsNoWayIGotTheNameOfThisPageWrong')]
|
||||
public function dropDatabase(EntityManagerInterface $em): Response
|
||||
{
|
||||
$entityClasses = array(
|
||||
|
||||
@ -33,12 +33,12 @@ use App\Entity\Edition;
|
||||
class MapApiController extends AbstractController
|
||||
{
|
||||
//function get_Name($rep) {return $rep->getName();}
|
||||
#[Route('/api/teapot')]
|
||||
#[Route('/teapot')]
|
||||
public function teapot(PlaceNameRepository $pNRep, RoomUserNameRepository $uNRep, PlaceRepository $pRep, SiteRepository $sRep): JsonResponse
|
||||
{
|
||||
throw new HttpException(418);
|
||||
}
|
||||
#[Route('/api/map/test')]
|
||||
#[Route('/map/test')]
|
||||
public function test(PlaceNameRepository $pNRep, RoomUserNameRepository $uNRep, PlaceRepository $pRep, SiteRepository $sRep): JsonResponse
|
||||
{
|
||||
$place0 = $pRep->findPlaceById(1)[0];
|
||||
@ -54,7 +54,7 @@ class MapApiController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/api/map/get_site_name/{id}')]
|
||||
#[Route('/map/get_site_name/{id}')]
|
||||
public function get_site_name(SiteRepository $rep, int $id): JsonResponse
|
||||
{
|
||||
$sites = $rep->findSiteById($id);
|
||||
@ -63,7 +63,7 @@ class MapApiController extends AbstractController
|
||||
return $this->json($sites[0]->getName());
|
||||
}
|
||||
|
||||
#[Route('/api/map/get_building_name/{id}')]
|
||||
#[Route('/map/get_building_name/{id}')]
|
||||
public function get_building_name(BuildingRepository $rep, int $id): JsonResponse
|
||||
{
|
||||
$buildings = $rep->findBuildingById($id);
|
||||
@ -72,7 +72,7 @@ class MapApiController extends AbstractController
|
||||
return $this->json($buildings[0]->getName());
|
||||
}
|
||||
|
||||
#[Route('/api/map/get_floor_name/{id}')]
|
||||
#[Route('/map/get_floor_name/{id}')]
|
||||
public function get_floor_name(FloorRepository $rep, int $id): JsonResponse
|
||||
{
|
||||
$floors = $rep->findFloorById($id);
|
||||
@ -81,7 +81,7 @@ class MapApiController extends AbstractController
|
||||
return $this->json($floors[0]->getName());
|
||||
}
|
||||
|
||||
#[Route('/api/map/get_floor/{id}/{representation}')]
|
||||
#[Route('/map/get_floor/{id}/{representation}')]
|
||||
public function get_floor(FloorRepository $rep, int $id, string $representation='Cylinder'): JsonResponse
|
||||
{
|
||||
//id is the floor's id, representation being Cylinder or PolySurface or other if implemented
|
||||
@ -117,7 +117,7 @@ class MapApiController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/api/map/get_all_floors/')]
|
||||
#[Route('/map/get_all_floors/')]
|
||||
public function get_all_floors(SiteRepository $sRep): JsonResponse
|
||||
{
|
||||
$sites = $sRep->allSites();
|
||||
@ -136,7 +136,7 @@ class MapApiController extends AbstractController
|
||||
return $this->json($response);
|
||||
}
|
||||
|
||||
#[Route('/api/map/find_place_by_name/{name}')]
|
||||
#[Route('/map/find_place_by_name/{name}')]
|
||||
public function find_place_by_name(PlaceRepository $rep, string $name): JsonResponse
|
||||
{
|
||||
$result = array();
|
||||
@ -160,7 +160,7 @@ class MapApiController extends AbstractController
|
||||
}
|
||||
|
||||
|
||||
#[Route('/api/map/get_place_info/{id}')]
|
||||
#[Route('/map/get_place_info/{id}')]
|
||||
public function get_place_info(PlaceRepository $rep, int $id): JsonResponse
|
||||
{
|
||||
$places = $rep->findPlaceById($id);
|
||||
@ -176,7 +176,7 @@ class MapApiController extends AbstractController
|
||||
}
|
||||
}
|
||||
|
||||
#[Route('/api/map/get_all_editions')]
|
||||
#[Route('/map/get_all_editions')]
|
||||
public function getEditions(EditionRepository $rep): JsonResponse
|
||||
{
|
||||
$listEdits = array();
|
||||
@ -192,7 +192,7 @@ class MapApiController extends AbstractController
|
||||
return $this->json($listEdits);
|
||||
}
|
||||
|
||||
#[Route('/api/map/create_edition/{mode}/{placeId}/{value}')]
|
||||
#[Route('/map/create_edition/{mode}/{placeId}/{value}')]
|
||||
public function createEdition(EditionRepository $Erep, PlaceRepository $Prep, string $mode, int $placeId, string $value): JsonResponse
|
||||
{
|
||||
//mode is the type of modification, can be AddPlaceName ; DelPlaceName ; AddRoomUserName or DelRoomUserName
|
||||
@ -202,7 +202,7 @@ class MapApiController extends AbstractController
|
||||
return $this->json(["added"]);
|
||||
}
|
||||
|
||||
#[Route('/api/map/remove_edition/{id}')]
|
||||
#[Route('/map/remove_edition/{id}')]
|
||||
public function removeEdition(EditionRepository $rep, int $id): JsonResponse
|
||||
{
|
||||
$edit = $rep->findEditionById($id);
|
||||
@ -212,7 +212,7 @@ class MapApiController extends AbstractController
|
||||
return $this->json(["removed"]);
|
||||
}
|
||||
|
||||
#[Route('/api/map/add_place_name/{placeId}/{value}')]
|
||||
#[Route('/map/add_place_name/{placeId}/{value}')]
|
||||
public function addPlaceName(PlaceRepository $pRep, PlaceNameRepository $pNRep, int $placeId, string $value): JsonResponse
|
||||
{
|
||||
$places = $pRep->findPlaceById($placeId);
|
||||
@ -231,7 +231,7 @@ class MapApiController extends AbstractController
|
||||
}
|
||||
}
|
||||
}
|
||||
#[Route('/api/map/del_place_name/{placeId}/{value}')]
|
||||
#[Route('/map/del_place_name/{placeId}/{value}')]
|
||||
public function delPlaceName(PlaceNameRepository $pNRep, int $placeId, string $value): JsonResponse
|
||||
{
|
||||
$pN = $pNRep->findPlaceName($placeId, $value);
|
||||
@ -241,7 +241,7 @@ class MapApiController extends AbstractController
|
||||
}
|
||||
|
||||
|
||||
#[Route('/api/map/add_room_user_name/{placeId}/{value}')]
|
||||
#[Route('/map/add_room_user_name/{placeId}/{value}')]
|
||||
public function addRoomUserName(PlaceRepository $pRep, RoomUserNameRepository $rURep, int $placeId, string $value): JsonResponse
|
||||
{
|
||||
$places = $pRep->findPlaceById($placeId);
|
||||
@ -260,7 +260,7 @@ class MapApiController extends AbstractController
|
||||
}
|
||||
}
|
||||
}
|
||||
#[Route('/api/map/del_room_user_name/{placeId}/{value}')]
|
||||
#[Route('/map/del_room_user_name/{placeId}/{value}')]
|
||||
public function delRoomUserName(RoomUserNameRepository $uRep, int $placeId, string $value): JsonResponse
|
||||
{
|
||||
$rU = $uRep->findRoomUserName($placeId, $value);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user