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 {