From 79f10ad7addbe140368a7b2706ad53cde015328c Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 11 Nov 2023 11:45:06 +0100 Subject: [PATCH 1/2] Reorder class properties --- packages/realtime-compiler/src/Http/DashboardController.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/realtime-compiler/src/Http/DashboardController.php b/packages/realtime-compiler/src/Http/DashboardController.php index ff5c44bcc86..37f9ac98c02 100644 --- a/packages/realtime-compiler/src/Http/DashboardController.php +++ b/packages/realtime-compiler/src/Http/DashboardController.php @@ -39,8 +39,9 @@ class DashboardController protected Request $request; protected ConsoleOutput $console; - protected bool $isAsync = false; + protected JsonResponse $response; + protected bool $isAsync = false; protected array $flashes = []; protected static array $tips = [ @@ -51,8 +52,6 @@ class DashboardController 'The dashboard update your project files. You can disable this by setting `server.dashboard.interactive` to `false` in `config/hyde.php`.', ]; - protected JsonResponse $response; - public function __construct() { $this->title = config('hyde.name').' - Dashboard'; From ccad9dc2ac90c3da163bb9ce40d038729e7a6b74 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 11 Nov 2023 11:45:14 +0100 Subject: [PATCH 2/2] Extract helper --- .../realtime-compiler/src/Http/DashboardController.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/realtime-compiler/src/Http/DashboardController.php b/packages/realtime-compiler/src/Http/DashboardController.php index 37f9ac98c02..1e282a4f4f5 100644 --- a/packages/realtime-compiler/src/Http/DashboardController.php +++ b/packages/realtime-compiler/src/Http/DashboardController.php @@ -61,7 +61,7 @@ public function __construct() $this->loadFlashData(); if ($this->request->method === 'POST') { - $this->isAsync = (getallheaders()['X-RC-Handler'] ?? getallheaders()['x-rc-handler'] ?? null) === 'Async'; + $this->isAsync = $this->hasAsyncHeaders(); } } @@ -505,4 +505,9 @@ protected function matchStatusCode(int $statusCode): string default => 'Internal Server Error', }; } + + protected function hasAsyncHeaders(): bool + { + return (getallheaders()['X-RC-Handler'] ?? getallheaders()['x-rc-handler'] ?? null) === 'Async'; + } }