Skip to content

Commit

Permalink
feat: add allowed methods to routes
Browse files Browse the repository at this point in the history
  • Loading branch information
joelbeckmann committed Jun 30, 2023
1 parent 3832ab9 commit 80b0c2b
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 36 deletions.
8 changes: 4 additions & 4 deletions src/Controller/AdministrationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct(
) {
}

#[Route(path: '/admin/user', name: 'admin_user')]
#[Route(path: '/admin/user', name: 'admin_user', methods: ['GET'])]
public function listUser(): Response
{
$this->logger->debug('AdministrationController::listUser: Enter');
Expand All @@ -35,7 +35,7 @@ public function listUser(): Response
);
}

#[Route(path: '/admin/user/{uid}', name: 'admin_user_edit')]
#[Route(path: '/admin/user/{uid}', name: 'admin_user_edit', methods: ['GET'])]
public function editUserDetails(Request $request, string $uid): Response
{
$this->logger->debug("AdministrationController::editUserDetails: Enter with uuid: {$uid}");
Expand All @@ -56,7 +56,7 @@ public function editUserDetails(Request $request, string $uid): Response
]);
}

#[Route(path: '/admin/studies', name: 'admin_studies')]
#[Route(path: '/admin/studies', name: 'admin_studies', methods: ['GET'])]
public function listStudies(): Response
{
$this->logger->debug('AdministrationController::listStudies: Enter');
Expand All @@ -70,7 +70,7 @@ public function listStudies(): Response
);
}

#[Route(path: '/admin/user/{uid}/studies', name: 'admin_user_studies')]
#[Route(path: '/admin/user/{uid}/studies', name: 'admin_user_studies', methods: ['GET'])]
public function listStudiesForUser(string $uid): Response
{
$this->logger->debug('AdministrationController::listStudies: Enter');
Expand Down
8 changes: 4 additions & 4 deletions src/Controller/CodebookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ public function __construct(protected EntityManagerInterface $em, protected Logg
{
}

#[Route(path: '/{uuid}', name: 'index')]
#[Route(path: '/{uuid}', name: 'index', methods: ['GET'])]
public function codebookIndexAction(string $uuid): Response
{
return $this->render('pages/codebook/index.html.twig', [
'codebook' => $this->em->getRepository(Dataset::class)->find($uuid),
]);
}

#[Route(path: '/{uuid}/data', name: 'dataupdate')]
#[Route(path: '/{uuid}/data', name: 'dataupdate', methods: ['GET', 'POST'])]
public function performUpdateAction(string $uuid, Request $request): JsonResponse
{
$this->logger->debug("Enter CodebookController::performUpdateAction with [UUID: {$uuid}]");
Expand All @@ -49,7 +49,7 @@ public function performUpdateAction(string $uuid, Request $request): JsonRespons
return new JsonResponse($jsonCodebook, $jsonCodebook != null && sizeof($jsonCodebook) > 0 ? Response::HTTP_OK : Response::HTTP_NO_CONTENT);
}

#[Route(path: '/{uuid}/measures', name: 'measures')]
#[Route(path: '/{uuid}/measures', name: 'measures', methods: ['GET'])]
public function createViewMeasuresAction(string $uuid): JsonResponse
{
$this->logger->debug("Enter CodebookController::createViewMeasuresAction with [UUID: {$uuid}]");
Expand All @@ -69,7 +69,7 @@ public function createViewMeasuresAction(string $uuid): JsonResponse
return new JsonResponse($viewMeasures, key_exists('measures', $viewMeasures) ? Response::HTTP_OK : Response::HTTP_NO_CONTENT);
}

#[Route(path: '/{uuid}/matrix', name: 'matrix')]
#[Route(path: '/{uuid}/matrix', name: 'matrix', methods: ['GET'])]
public function datasetMatrixAction(Request $request, string $uuid): JsonResponse
{
$size = $request->get('size') ?? 0;
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@

class DashboardController extends AbstractController
{
#[Route(path: '/', name: 'landing')]
#[Route(path: '/', name: 'landing', methods: ['GET'])]
public function landingAction(): Response
{
return $this->render('pages/administration/landing.html.twig');
}

#[Route(path: '/dashboard', name: 'dashboard')]
#[Route(path: '/dashboard', name: 'dashboard', methods: ['GET'])]
#[IsGranted('ROLE_USER')]
public function dashboardAction(): Response
{
Expand Down
12 changes: 6 additions & 6 deletions src/Controller/FileManagementController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct(
) {
}

#[Route(path: '/preview/sav/{fileId}', name: 'preview-sav')]
#[Route(path: '/preview/sav/{fileId}', name: 'preview-sav', methods: ['POST'])]
public function previewSavAction(string $fileId): JsonResponse
{
$this->logger->debug("Enter FileManagementController::previewSavAction with [FileId: {$fileId}]");
Expand All @@ -44,7 +44,7 @@ public function previewSavAction(string $fileId): JsonResponse
return new JsonResponse($data ?? [], $data != null ? Response::HTTP_OK : Response::HTTP_UNPROCESSABLE_ENTITY);
}

#[Route(path: '/submit/sav/{fileId}', name: 'submit-sav')]
#[Route(path: '/submit/sav/{fileId}', name: 'submit-sav', methods: ['POST'])]
public function submitSavAction(string $fileId): JsonResponse
{
$this->logger->debug("Enter FileManagementController::previewSavAction with [FileId: {$fileId}]");
Expand Down Expand Up @@ -78,7 +78,7 @@ public function submitSavAction(string $fileId): JsonResponse
return new JsonResponse($data ?? [], $data != null ? Response::HTTP_OK : Response::HTTP_UNPROCESSABLE_ENTITY);
}

#[Route(path: '/preview/csv/{fileId}', name: 'preview-csv')]
#[Route(path: '/preview/csv/{fileId}', name: 'preview-csv', methods: ['POST'])]
public function previewCsvAction(string $fileId, Request $request): JsonResponse
{
$this->logger->debug("Enter FileManagementController::previewCSVAction with [FileId: {$fileId}]");
Expand All @@ -94,7 +94,7 @@ public function previewCsvAction(string $fileId, Request $request): JsonResponse
return new JsonResponse($data, $data ? Response::HTTP_OK : Response::HTTP_UNPROCESSABLE_ENTITY);
}

#[Route(path: '/submit/csv/{fileId}', name: 'submit-csv')]
#[Route(path: '/submit/csv/{fileId}', name: 'submit-csv', methods: ['POST'])]
public function submitCSVAction(string $fileId, Request $request): JsonResponse
{
$this->logger->debug("Enter FileManagementController::submitCSVAction with [FileId: {$fileId}]");
Expand Down Expand Up @@ -145,7 +145,7 @@ public function submitCSVAction(string $fileId, Request $request): JsonResponse
);
}

#[Route(path: '/{uuid}/delete/dataset', name: 'delete_dataset')]
#[Route(path: '/{uuid}/delete/dataset', name: 'delete_dataset', methods: ['POST'])]
public function deleteDatasetAction(string $uuid): RedirectResponse
{
$this->logger->debug("Enter FileManagementController::deleteMaterialAction with [UUID: {$uuid}]");
Expand All @@ -156,7 +156,7 @@ public function deleteDatasetAction(string $uuid): RedirectResponse
return $this->redirectToRoute('Study-datasets', ['uuid' => $experimentId]);
}

#[Route(path: '/{uuid}/delete/material', name: 'delete_material')]
#[Route(path: '/{uuid}/delete/material', name: 'delete_material', methods: ['POST'])]
public function deleteMaterialAction(string $uuid): RedirectResponse
{
$this->logger->debug("Enter FileManagementController::deleteMaterialAction with [UUID: {$uuid}]");
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/ModerationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function __construct(
) {
}

#[Route(path: '/moderation/dashboard', name: 'moderation_dashboard')]
#[Route(path: '/moderation/dashboard', name: 'moderation_dashboard', methods: ['GET'])]
public function dashboard(): Response
{
$this->logger->debug('AdministrationController::dashboard: Enter');
Expand Down
10 changes: 5 additions & 5 deletions src/Controller/OauthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ public function __construct(private readonly ClientRegistry $clientRegistry)
{
}

#[Route(path: '/login', name: 'login')]
#[Route(path: '/login', name: 'login', methods: ['GET'])]
public function loginAction(): RedirectResponse
{
return $this->clientRegistry->getClient('keycloak')->redirect(['openid'], []);
}

#[Route(path: '/logout', name: 'logout')]
public function loginCheckAction(ClientRegistry $clientRegistry)
#[Route(path: '/logout', name: 'logout', methods: ['GET'])]
public function logoutAction(ClientRegistry $clientRegistry)
{
}

#[Route(path: '/login/check', name: 'check')]
public function logoutAction()
#[Route(path: '/login/check', name: 'check', methods: ['GET'])]
public function loginCheckAction()
{
}
}
2 changes: 1 addition & 1 deletion src/Controller/ReviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function __construct(private readonly EntityManagerInterface $em)
{
}

#[Route(path: 'review/{uuid}', name: 'Study-review')]
#[Route(path: 'review/{uuid}', name: 'Study-review', methods: ['GET'])]
public function reviewAction(string $uuid): Response
{
$experiment = $this->em->getRepository(Experiment::class)->find($uuid);
Expand Down
24 changes: 12 additions & 12 deletions src/Controller/StudyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(
) {
}

#[Route(path: '/', name: 'overview')]
#[Route(path: '/', name: 'overview', methods: ['GET'])]
public function overviewAction(): Response
{
$this->logger->debug('Enter StudyController::overviewAction');
Expand All @@ -46,7 +46,7 @@ public function overviewAction(): Response
/**
* @noinspection PhpPossiblePolymorphicInvocationInspection
*/
#[Route(path: '/new', name: 'new')]
#[Route(path: '/new', name: 'new', methods: ['GET', 'POST'])]
public function newAction(Questionnairable $questionnaire, Request $request): Response
{
$this->logger->debug('Enter StudyController::newAction');
Expand All @@ -69,7 +69,7 @@ public function newAction(Questionnairable $questionnaire, Request $request): Re
]);
}

#[Route(path: '/{uuid}/settings', name: 'settings')]
#[Route(path: '/{uuid}/settings', name: 'settings', methods: ['GET'])]
public function settingsAction(string $uuid, Request $request): Response
{
$this->logger->debug("Enter StudyController::settingsAction with [UUID: {$uuid}]");
Expand All @@ -95,7 +95,7 @@ public function settingsAction(string $uuid, Request $request): Response
/**
* @noinspection PhpPossiblePolymorphicInvocationInspection
*/
#[Route(path: '/{uuid}/documentation', name: 'documentation')]
#[Route(path: '/{uuid}/documentation', name: 'documentation', methods: ['GET', 'POST'])]
public function documentationAction(string $uuid, Request $request): Response
{
$this->logger->debug("Enter StudyController::documentationAction with [UUID: {$uuid}]");
Expand Down Expand Up @@ -155,7 +155,7 @@ public function documentationAction(string $uuid, Request $request): Response
/**
* @noinspection PhpPossiblePolymorphicInvocationInspection
*/
#[Route(path: '/{uuid}/theory', name: 'theory')]
#[Route(path: '/{uuid}/theory', name: 'theory', methods: ['GET', 'POST'])]
public function theoryAction(string $uuid, Request $request): Response
{
$this->logger->debug("Enter StudyController::theoryAction with [UUID: {$uuid}]");
Expand Down Expand Up @@ -192,7 +192,7 @@ public function theoryAction(string $uuid, Request $request): Response
/**
* @noinspection PhpPossiblePolymorphicInvocationInspection
*/
#[Route(path: '/{uuid}/sample', name: 'sample')]
#[Route(path: '/{uuid}/sample', name: 'sample', methods: ['GET', 'POST'])]
public function sampleAction(string $uuid, Request $request): Response
{
$this->logger->debug("Enter StudyController::sampleAction with [UUID: {$uuid}]");
Expand Down Expand Up @@ -234,7 +234,7 @@ public function sampleAction(string $uuid, Request $request): Response
/**
* @noinspection PhpPossiblePolymorphicInvocationInspection
*/
#[Route(path: '/{uuid}/measure', name: 'measure')]
#[Route(path: '/{uuid}/measure', name: 'measure', methods: ['GET', 'POST'])]
public function measureAction(string $uuid, Request $request): Response
{
$this->logger->debug("Enter StudyController::measureAction with [UUID: {$uuid}]");
Expand Down Expand Up @@ -275,7 +275,7 @@ public function measureAction(string $uuid, Request $request): Response
/**
* @noinspection PhpPossiblePolymorphicInvocationInspection
*/
#[Route(path: '/{uuid}/method', name: 'method')]
#[Route(path: '/{uuid}/method', name: 'method', methods: ['GET', 'POST'])]
public function methodAction(string $uuid, Request $request): Response
{
$this->logger->debug("Enter StudyController::methodAction with [UUID: {$uuid}]");
Expand Down Expand Up @@ -309,7 +309,7 @@ public function methodAction(string $uuid, Request $request): Response
]);
}

#[Route(path: '/{uuid}/materials', name: 'materials')]
#[Route(path: '/{uuid}/materials', name: 'materials', methods: ['GET'])]
public function materialsAction(string $uuid): Response
{
$this->logger->debug("Enter StudyController::materialsAction with [UUID: {$uuid}]");
Expand All @@ -324,7 +324,7 @@ public function materialsAction(string $uuid): Response
]);
}

#[Route(path: '/{uuid}/datasets', name: 'datasets')]
#[Route(path: '/{uuid}/datasets', name: 'datasets', methods: ['GET'])]
public function datasetsAction(string $uuid): Response
{
$this->logger->debug("Enter StudyController::datasetsAction with [UUID: {$uuid}]");
Expand All @@ -339,7 +339,7 @@ public function datasetsAction(string $uuid): Response
]);
}

#[Route(path: '/{uuid}/introduction', name: 'introduction')]
#[Route(path: '/{uuid}/introduction', name: 'introduction', methods: ['GET'])]
public function introductionAction(string $uuid): Response
{
$this->logger->debug("Enter StudyController::introductionAction with [UUID: {$uuid}]");
Expand All @@ -354,7 +354,7 @@ public function introductionAction(string $uuid): Response
]);
}

#[Route(path: '/{uuid}/delete', name: 'delete')]
#[Route(path: '/{uuid}/delete', name: 'delete', methods: ['GET'])]
public function deleteAction(string $uuid): Response
{
$this->logger->debug("Enter StudyController::deleteAction with [UUID: {$uuid}]");
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct(private readonly LoggerInterface $logger, private re
/**
* @throws \Exception
*/
#[Route(path: '/admin/install', name: 'dw_install')]
#[Route(path: '/admin/install', name: 'dw_install', methods: ['GET'])]
public function installDW(): Response
{
$this->logger->debug('UserController::installDW: Enter');
Expand Down

0 comments on commit 80b0c2b

Please sign in to comment.