Unify RPC endpoint naming
authorMarcel Werk <burntime@woltlab.com>
Tue, 3 Dec 2024 14:42:38 +0000 (15:42 +0100)
committerMarcel Werk <burntime@woltlab.com>
Tue, 3 Dec 2024 14:42:38 +0000 (15:42 +0100)
ts/WoltLabSuite/Core/Api/Gridviews/GetRows.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Api/Gridviews/GetRows.js
wcfsetup/install/files/lib/bootstrap/com.woltlab.wcf.php
wcfsetup/install/files/lib/system/endpoint/controller/core/gridViews/GetRows.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/endpoint/controller/core/gridviews/GetRows.class.php [deleted file]

index 142f6b15b69a872561fff3225968768d20d45cbc..3ebbc399b025a0f67f28018fa48d4bd41b215204 100644 (file)
@@ -16,7 +16,7 @@ export async function getRows(
   filters?: Map<string, string>,
   gridViewParameters?: Map<string, string>,
 ): Promise<ApiResult<Response>> {
-  const url = new URL(`${window.WSC_RPC_API_URL}core/gridviews/rows`);
+  const url = new URL(`${window.WSC_RPC_API_URL}core/grid-views/rows`);
   url.searchParams.set("gridView", gridViewClass);
   url.searchParams.set("pageNo", pageNo.toString());
   url.searchParams.set("sortField", sortField);
index 8e0931892b884167d4f771e6ddc15bc3ae8314af..f85f33a7d7a778b8652b6882bf86ad25e251cc24 100644 (file)
@@ -3,7 +3,7 @@ define(["require", "exports", "WoltLabSuite/Core/Ajax/Backend", "../Result"], fu
     Object.defineProperty(exports, "__esModule", { value: true });
     exports.getRows = getRows;
     async function getRows(gridViewClass, pageNo, sortField = "", sortOrder = "ASC", filters, gridViewParameters) {
-        const url = new URL(`${window.WSC_RPC_API_URL}core/gridviews/rows`);
+        const url = new URL(`${window.WSC_RPC_API_URL}core/grid-views/rows`);
         url.searchParams.set("gridView", gridViewClass);
         url.searchParams.set("pageNo", pageNo.toString());
         url.searchParams.set("sortField", sortField);
index 22f5a5a0a2517187e1e846b45150155fdc294a3f..60ddb452b2c35066c45c23f862f4439c3dd2c443 100644 (file)
@@ -135,7 +135,7 @@ return static function (): void {
             $event->register(new \wcf\system\endpoint\controller\core\comments\responses\RenderResponses);
             $event->register(new \wcf\system\endpoint\controller\core\comments\responses\UpdateResponse);
             $event->register(new \wcf\system\endpoint\controller\core\exceptions\RenderException);
-            $event->register(new \wcf\system\endpoint\controller\core\gridviews\GetRows);
+            $event->register(new \wcf\system\endpoint\controller\core\gridViews\GetRows);
             $event->register(new \wcf\system\endpoint\controller\core\messages\GetMentionSuggestions);
             $event->register(new \wcf\system\endpoint\controller\core\sessions\DeleteSession);
             $event->register(new \wcf\system\endpoint\controller\core\users\options\DeleteOption);
diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/gridViews/GetRows.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/gridViews/GetRows.class.php
new file mode 100644 (file)
index 0000000..a4b8185
--- /dev/null
@@ -0,0 +1,82 @@
+<?php
+
+namespace wcf\system\endpoint\controller\core\gridViews;
+
+use Laminas\Diactoros\Response\JsonResponse;
+use Psr\Http\Message\ResponseInterface;
+use Psr\Http\Message\ServerRequestInterface;
+use wcf\http\Helper;
+use wcf\system\endpoint\GetRequest;
+use wcf\system\endpoint\IController;
+use wcf\system\exception\PermissionDeniedException;
+use wcf\system\exception\UserInputException;
+use wcf\system\gridView\AbstractGridView;
+
+/**
+ * Retrieves the rows for a grid view.
+ *
+ * @author      Marcel Werk
+ * @copyright   2001-2024 WoltLab GmbH
+ * @license     GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since       6.2
+ */
+#[GetRequest('/core/grid-views/rows')]
+final class GetRows implements IController
+{
+    #[\Override]
+    public function __invoke(ServerRequestInterface $request, array $variables): ResponseInterface
+    {
+        $parameters = Helper::mapApiParameters($request, GetRowsParameters::class);
+
+        if (!\is_subclass_of($parameters->gridView, AbstractGridView::class)) {
+            throw new UserInputException('gridView', 'invalid');
+        }
+
+        $view = new $parameters->gridView(...$parameters->gridViewParameters);
+        \assert($view instanceof AbstractGridView);
+
+        if (!$view->isAccessible()) {
+            throw new PermissionDeniedException();
+        }
+
+        $view->setPageNo($parameters->pageNo);
+        if ($parameters->sortField) {
+            $view->setSortField($parameters->sortField);
+        }
+        if ($parameters->sortOrder) {
+            $view->setSortOrder($parameters->sortOrder);
+        }
+
+        if ($parameters->filters !== []) {
+            $view->setActiveFilters($parameters->filters);
+        }
+
+        $filterLabels = [];
+        foreach (\array_keys($parameters->filters) as $key) {
+            $filterLabels[$key] = $view->getFilterLabel($key);
+        }
+
+        return new JsonResponse([
+            'template' => $view->renderRows(),
+            'pages' => $view->countPages(),
+            'totalRows' => $view->countRows(),
+            'filterLabels' => $filterLabels,
+        ]);
+    }
+}
+
+/** @internal */
+final class GetRowsParameters
+{
+    public function __construct(
+        /** @var non-empty-string */
+        public readonly string $gridView,
+        public readonly int $pageNo,
+        public readonly string $sortField,
+        public readonly string $sortOrder,
+        /** @var string[] */
+        public readonly array $filters,
+        /** @var string[] */
+        public readonly array $gridViewParameters,
+    ) {}
+}
diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/gridviews/GetRows.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/gridviews/GetRows.class.php
deleted file mode 100644 (file)
index a2dc415..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-<?php
-
-namespace wcf\system\endpoint\controller\core\gridviews;
-
-use Laminas\Diactoros\Response\JsonResponse;
-use Psr\Http\Message\ResponseInterface;
-use Psr\Http\Message\ServerRequestInterface;
-use wcf\http\Helper;
-use wcf\system\endpoint\GetRequest;
-use wcf\system\endpoint\IController;
-use wcf\system\exception\PermissionDeniedException;
-use wcf\system\exception\UserInputException;
-use wcf\system\gridView\AbstractGridView;
-
-/**
- * Retrieves the rows for a grid view.
- *
- * @author      Marcel Werk
- * @copyright   2001-2024 WoltLab GmbH
- * @license     GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @since       6.2
- */
-#[GetRequest('/core/gridviews/rows')]
-final class GetRows implements IController
-{
-    #[\Override]
-    public function __invoke(ServerRequestInterface $request, array $variables): ResponseInterface
-    {
-        $parameters = Helper::mapApiParameters($request, GetRowsParameters::class);
-
-        if (!\is_subclass_of($parameters->gridView, AbstractGridView::class)) {
-            throw new UserInputException('gridView', 'invalid');
-        }
-
-        $view = new $parameters->gridView(...$parameters->gridViewParameters);
-        \assert($view instanceof AbstractGridView);
-
-        if (!$view->isAccessible()) {
-            throw new PermissionDeniedException();
-        }
-
-        $view->setPageNo($parameters->pageNo);
-        if ($parameters->sortField) {
-            $view->setSortField($parameters->sortField);
-        }
-        if ($parameters->sortOrder) {
-            $view->setSortOrder($parameters->sortOrder);
-        }
-
-        if ($parameters->filters !== []) {
-            $view->setActiveFilters($parameters->filters);
-        }
-
-        $filterLabels = [];
-        foreach (\array_keys($parameters->filters) as $key) {
-            $filterLabels[$key] = $view->getFilterLabel($key);
-        }
-
-        return new JsonResponse([
-            'template' => $view->renderRows(),
-            'pages' => $view->countPages(),
-            'totalRows' => $view->countRows(),
-            'filterLabels' => $filterLabels,
-        ]);
-    }
-}
-
-/** @internal */
-final class GetRowsParameters
-{
-    public function __construct(
-        /** @var non-empty-string */
-        public readonly string $gridView,
-        public readonly int $pageNo,
-        public readonly string $sortField,
-        public readonly string $sortOrder,
-        /** @var string[] */
-        public readonly array $filters,
-        /** @var string[] */
-        public readonly array $gridViewParameters,
-    ) {}
-}