[TASK] Reveal usage as controller of TaskStatus::class 83/58183/5
authorAnja <aleichsenring@ab-softlab.de>
Tue, 4 Sep 2018 12:27:10 +0000 (14:27 +0200)
committerGeorg Ringer <georg.ringer@gmail.com>
Wed, 5 Sep 2018 08:55:13 +0000 (10:55 +0200)
The class is called by two ajax routes and is therefore to be named,
placed and handled as the controller that it is.

Change-Id: I5106f5310041d3f0a993c2bf7ebe03ac51454cad
Resolves: #86142
Releases: master
Reviewed-on: https://review.typo3.org/58183
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Guido Schmechel <guido.schmechel@brandung.de>
Tested-by: Guido Schmechel <guido.schmechel@brandung.de>
Reviewed-by: Mathias Brodala <mbrodala@pagemachine.de>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/taskcenter/Classes/Controller/TaskStatusController.php [new file with mode: 0644]
typo3/sysext/taskcenter/Classes/TaskStatus.php [deleted file]
typo3/sysext/taskcenter/Configuration/Backend/AjaxRoutes.php

diff --git a/typo3/sysext/taskcenter/Classes/Controller/TaskStatusController.php b/typo3/sysext/taskcenter/Classes/Controller/TaskStatusController.php
new file mode 100644 (file)
index 0000000..85caf79
--- /dev/null
@@ -0,0 +1,75 @@
+<?php
+namespace TYPO3\CMS\Taskcenter\Controller;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use Psr\Http\Message\ResponseInterface;
+use Psr\Http\Message\ServerRequestInterface;
+use TYPO3\CMS\Core\Http\JsonResponse;
+
+/**
+ * Status of tasks
+ */
+class TaskStatusController
+{
+    /**
+     * Saves the section toggle state of tasks in the backend user's uc
+     *
+     * @param ServerRequestInterface $request
+     * @return ResponseInterface
+     */
+    public function saveCollapseState(ServerRequestInterface $request): ResponseInterface
+    {
+        // Remove 'el_' in the beginning which is needed for the saveSortingState()
+        $item = $request->getParsedBody()['item'] ?? $request->getQueryParams()['item'];
+        $item = htmlspecialchars($item);
+        $state = (bool)($request->getParsedBody()['state'] ?? $request->getQueryParams()['state']);
+
+        $this->getBackendUserAuthentication()->uc['taskcenter']['states'][$item] = $state;
+        $this->getBackendUserAuthentication()->writeUC();
+
+        return new JsonResponse(null);
+    }
+
+    /**
+     * Saves the sorting order of tasks in the backend user's uc
+     *
+     * @param ServerRequestInterface $request
+     * @return ResponseInterface
+     */
+    public function saveSortingState(ServerRequestInterface $request): ResponseInterface
+    {
+        $sort = [];
+        $data = $request->getParsedBody()['data'] ?? $request->getQueryParams()['data'];
+
+        $items = explode('&', $data);
+        foreach ($items as $item) {
+            $sort[] = substr($item, 12);
+        }
+        $this->getBackendUserAuthentication()->uc['taskcenter']['sorting'] = serialize($sort);
+        $this->getBackendUserAuthentication()->writeUC();
+
+        return new JsonResponse(null);
+    }
+
+    /**
+     * Returns BackendUserAuthentication
+     *
+     * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
+     */
+    protected function getBackendUserAuthentication()
+    {
+        return $GLOBALS['BE_USER'];
+    }
+}
diff --git a/typo3/sysext/taskcenter/Classes/TaskStatus.php b/typo3/sysext/taskcenter/Classes/TaskStatus.php
deleted file mode 100644 (file)
index d67297e..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-<?php
-namespace TYPO3\CMS\Taskcenter;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-use Psr\Http\Message\ResponseInterface;
-use Psr\Http\Message\ServerRequestInterface;
-use TYPO3\CMS\Core\Http\JsonResponse;
-
-/**
- * Status of tasks
- */
-class TaskStatus
-{
-    /**
-     * Saves the section toggle state of tasks in the backend user's uc
-     *
-     * @param ServerRequestInterface $request
-     * @return ResponseInterface
-     */
-    public function saveCollapseState(ServerRequestInterface $request): ResponseInterface
-    {
-        // Remove 'el_' in the beginning which is needed for the saveSortingState()
-        $item = $request->getParsedBody()['item'] ?? $request->getQueryParams()['item'];
-        $item = htmlspecialchars($item);
-        $state = (bool)($request->getParsedBody()['state'] ?? $request->getQueryParams()['state']);
-
-        $this->getBackendUserAuthentication()->uc['taskcenter']['states'][$item] = $state;
-        $this->getBackendUserAuthentication()->writeUC();
-
-        return new JsonResponse(null);
-    }
-
-    /**
-     * Saves the sorting order of tasks in the backend user's uc
-     *
-     * @param ServerRequestInterface $request
-     * @return ResponseInterface
-     */
-    public function saveSortingState(ServerRequestInterface $request): ResponseInterface
-    {
-        $sort = [];
-        $data = $request->getParsedBody()['data'] ?? $request->getQueryParams()['data'];
-
-        $items = explode('&', $data);
-        foreach ($items as $item) {
-            $sort[] = substr($item, 12);
-        }
-        $this->getBackendUserAuthentication()->uc['taskcenter']['sorting'] = serialize($sort);
-        $this->getBackendUserAuthentication()->writeUC();
-
-        return new JsonResponse(null);
-    }
-
-    /**
-     * Returns BackendUserAuthentication
-     *
-     * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
-     */
-    protected function getBackendUserAuthentication()
-    {
-        return $GLOBALS['BE_USER'];
-    }
-}
index 1aded1e..5a9ba8f 100644 (file)
@@ -4,15 +4,12 @@
  * Definitions for routes provided by EXT:taskcenter
  */
 return [
-    // Collapse
     'taskcenter_collapse' => [
         'path' => '/taskcenter/collapse',
-        'target' => \TYPO3\CMS\Taskcenter\TaskStatus::class . '::saveCollapseState'
+        'target' => \TYPO3\CMS\Taskcenter\Controller\TaskStatusController::class . '::saveCollapseState',
     ],
-
-    // Sort
     'taskcenter_sort' => [
         'path' => '/taskcenter/sort',
-        'target' => \TYPO3\CMS\Taskcenter\TaskStatus::class . '::saveSortingState'
-    ]
+        'target' => \TYPO3\CMS\Taskcenter\Controller\TaskStatusController::class . '::saveSortingState',
+    ],
 ];