]> BookStack Code Mirror - bookstack/blobdiff - app/Http/Controllers/Api/ApiController.php
Added ability to escape role "External Auth ID" commas
[bookstack] / app / Http / Controllers / Api / ApiController.php
index fc9788b06e340d405eb73b9d56fd5c1fb4290c5f..9652654be4d79a364d956149943cc266af7a6a18 100644 (file)
@@ -15,18 +15,27 @@ abstract class ApiController extends Controller
      * Provide a paginated listing JSON response in a standard format
      * taking into account any pagination parameters passed by the user.
      */
-    protected function apiListingResponse(Builder $query, array $fields): JsonResponse
+    protected function apiListingResponse(Builder $query, array $fields, array $modifiers = []): JsonResponse
     {
         $listing = new ListingResponseBuilder($query, request(), $fields);
 
+        foreach ($modifiers as $modifier) {
+            $listing->modifyResults($modifier);
+        }
+
         return $listing->toResponse();
     }
 
     /**
      * Get the validation rules for this controller.
+     * Defaults to a $rules property but can be a rules() method.
      */
-    public function getValdationRules(): array
+    public function getValidationRules(): array
     {
+        if (method_exists($this, 'rules')) {
+            return $this->rules();
+        }
+
         return $this->rules;
     }
 }