]> BookStack Code Mirror - bookstack/commitdiff
Refactor SettingController to validate categies by existing view files
authorLachlan Tripolone <redacted>
Thu, 10 Oct 2024 23:40:38 +0000 (10:40 +1100)
committerLachlan Tripolone <redacted>
Thu, 10 Oct 2024 23:40:38 +0000 (10:40 +1100)
app/Settings/SettingController.php

index bdbc3c78a392dce4bc97b7ae419f586147205b66..6ecc2bd1de177a54c41a3a7b1d31773f851b0d7a 100644 (file)
@@ -9,8 +9,6 @@ use Illuminate\Http\Request;
 
 class SettingController extends Controller
 {
-    protected array $settingCategories = ['features', 'customization', 'registration'];
-
     /**
      * Handle requests to the settings index path.
      */
@@ -59,8 +57,8 @@ class SettingController extends Controller
 
     protected function ensureCategoryExists(string $category): void
     {
-        if (!in_array($category, $this->settingCategories)) {
-            abort(404);
+        if (!view()->exists('settings.' . $category)) {
+            abort(404, 'Category not found');
         }
     }
 }