From 9a62155184d7fb1bf25443149c7014e10c863182 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Wed, 8 Nov 2023 19:17:40 +0100 Subject: [PATCH] Replace validation array with default match handler --- .../realtime-compiler/src/Http/DashboardController.php | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/packages/realtime-compiler/src/Http/DashboardController.php b/packages/realtime-compiler/src/Http/DashboardController.php index 971b8a21824..f7d22f2afb9 100644 --- a/packages/realtime-compiler/src/Http/DashboardController.php +++ b/packages/realtime-compiler/src/Http/DashboardController.php @@ -99,21 +99,14 @@ protected function show(): string protected function handlePostRequest(): JsonResponse { - $actions = array_combine($actions = [ - 'openInExplorer', - 'openPageInEditor', - 'openMediaFileInEditor', - 'createPage', - ], $actions); - $action = $this->request->data['action'] ?? $this->abort(400, 'Must provide action'); - $action = $actions[$action] ?? $this->abort(403, "Invalid action '$action'"); match ($action) { 'openInExplorer' => $this->openInExplorer(), 'openPageInEditor' => $this->openPageInEditor(), 'openMediaFileInEditor' => $this->openMediaFileInEditor(), 'createPage' => $this->createPage(), + default => $this->abort(403, "Invalid action '$action'"), }; return $this->response ?? new JsonResponse(200, 'OK', [