From 73331f26c353d742066f1b01bd872cb443999928 Mon Sep 17 00:00:00 2001 From: Leo Feyer <1192057+leofeyer@users.noreply.github.com> Date: Thu, 23 May 2024 12:40:55 +0200 Subject: [PATCH] Consolidate the route definitions in invokable controllers (see #7232) Description ----------- Follow-up on #7227 Commits ------- 970ade34 Fix the inconsistent `_store_referrer` configuration 366a331e Consolidate the route definitions --- core-bundle/src/Controller/BackendPreviewController.php | 5 +---- .../src/Controller/BackendPreviewSwitchController.php | 5 +---- .../src/Controller/InstallationController.php | 7 ++----- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/core-bundle/src/Controller/BackendPreviewController.php b/core-bundle/src/Controller/BackendPreviewController.php index e43ed0bfaf5..0bf86df3ff8 100644 --- a/core-bundle/src/Controller/BackendPreviewController.php +++ b/core-bundle/src/Controller/BackendPreviewController.php @@ -27,7 +27,7 @@ * requested front end page while ensuring that the /preview.php entry point is * used. When requested, the front end user gets authenticated. * - * @Route(path="%contao.backend.route_prefix%", defaults={"_scope" = "backend", "_allow_preview" = true, "_store_referrer" = false}) + * @Route("%contao.backend.route_prefix%/preview", name="contao_backend_preview", defaults={"_scope" = "backend", "_allow_preview" = true, "_store_referrer" = false}) */ class BackendPreviewController { @@ -44,9 +44,6 @@ public function __construct(string $previewScript, FrontendPreviewAuthenticator $this->authorizationChecker = $authorizationChecker; } - /** - * @Route("/preview", name="contao_backend_preview") - */ public function __invoke(Request $request): Response { // Skip the redirect if there is no preview script, otherwise we will diff --git a/core-bundle/src/Controller/BackendPreviewSwitchController.php b/core-bundle/src/Controller/BackendPreviewSwitchController.php index 40e63fdcfb5..0d2fdf12423 100644 --- a/core-bundle/src/Controller/BackendPreviewSwitchController.php +++ b/core-bundle/src/Controller/BackendPreviewSwitchController.php @@ -37,7 +37,7 @@ * b) Provide the member usernames for the datalist * c) Process the switch action (i.e. log in a specific front end user). * - * @Route(path="%contao.backend.route_prefix%", defaults={"_scope" = "backend", "_allow_preview" = true, "_store_referrer" = false}) + * @Route("%contao.backend.route_prefix%/preview_switch", name="contao_backend_switch", defaults={"_scope" = "backend", "_allow_preview" = true, "_store_referrer" = false}) */ class BackendPreviewSwitchController { @@ -66,9 +66,6 @@ public function __construct(FrontendPreviewAuthenticator $previewAuthenticator, $this->backendBadgeTitle = $badgeTitle; } - /** - * @Route("/preview_switch", name="contao_backend_switch") - */ public function __invoke(Request $request): Response { $user = $this->security->getUser(); diff --git a/installation-bundle/src/Controller/InstallationController.php b/installation-bundle/src/Controller/InstallationController.php index 401fdeaf018..5ea3491d039 100644 --- a/installation-bundle/src/Controller/InstallationController.php +++ b/installation-bundle/src/Controller/InstallationController.php @@ -30,7 +30,7 @@ use Symfony\Component\Routing\Annotation\Route; /** - * @Route("%contao.backend.route_prefix%", defaults={"_scope" = "backend", "_token_check" = true, "_store_referrer" = false}) + * @Route("%contao.backend.route_prefix%/install", name="contao_install", defaults={"_scope" = "backend", "_token_check" = true, "_store_referrer" = false}) * * @internal */ @@ -44,10 +44,7 @@ class InstallationController implements ContainerAwareInterface 'sql_message' => '', ]; - /** - * @Route("/install", name="contao_install") - */ - public function installAction(): Response + public function __invoke(): Response { if (null !== ($response = $this->initializeApplication())) { return $response;