From 5c4e088c0ba71277621098266b3eba19d561b0f1 Mon Sep 17 00:00:00 2001 From: Daniel Guzman Date: Sun, 11 Aug 2024 02:29:03 +0200 Subject: [PATCH] Fix --- src/Controller/LeagueController.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Controller/LeagueController.php b/src/Controller/LeagueController.php index 7568e14f..d3d761c5 100644 --- a/src/Controller/LeagueController.php +++ b/src/Controller/LeagueController.php @@ -23,9 +23,13 @@ class LeagueController extends AbstractController { return $handleCreateLeague($request); } - #[Route('/api/league/{$leagueId}', name: 'app_update_league', methods: ['PUT'])] - public function updateLeague(Request $request, HandleUpdateLeague $handleUpdateLeague, int $leagueId): JsonResponse + #[Route('/api/league/{leagueId}', name: 'app_get_put_league', methods: ['GET, PUT'])] + public function getOrUpdateLeagueById(Request $request, HandleGetLeagueById $handleGetLeagueById, HandleUpdateLeague $handleUpdateLeague, int $leagueId): JsonResponse { + if ($request->getMethod() == 'GET') + { + return $handleGetLeagueById($request, $leagueId); + } return $handleUpdateLeague($request, $leagueId); } @@ -44,12 +48,6 @@ class LeagueController extends AbstractController return $handleCaptainRequest($request, $leagueId, $teamId); } - #[Route('/api/league/{leagueId}', name: 'app_get_league', methods: ['GET'])] - public function getLeagueById(Request $request, HandleGetLeagueById $handleGetLeagueById, int $leagueId): JsonResponse - { - return $handleGetLeagueById($request, $leagueId); - } - #[Route('/api/public/league', name: 'app_get_all_leagues', methods: ['GET'])] public function getAllLeagues(HandleGetAllLeagues $handleGetAllLeagues): JsonResponse {