[TASK] Use ServerRequestInterface in SchedulerModuleController 64/56264/18
authorŁukasz Uznański <l.uznanski@macopedia.pl>
Fri, 16 Mar 2018 22:17:10 +0000 (23:17 +0100)
committerMathias Brodala <mbrodala@pagemachine.de>
Mon, 9 Jul 2018 07:25:11 +0000 (09:25 +0200)
* replace usages of _GP, getIndpEnv
* add return hints

Resolves: #84387
Releases: master
Change-Id: I156f9005c132ab91abfbd72b97084ede6708d0dc
Reviewed-on: https://review.typo3.org/56264
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Robert van Kammen <rvkammen@hotmail.com>
Tested-by: Robert van Kammen <rvkammen@hotmail.com>
Reviewed-by: Mathias Brodala <mbrodala@pagemachine.de>
Tested-by: Mathias Brodala <mbrodala@pagemachine.de>
18 files changed:
typo3/sysext/core/Documentation/Changelog/master/Deprecation-84387-DeprecatedMethodAndPropertyInSchedulerModuleController.rst [new file with mode: 0644]
typo3/sysext/extbase/Classes/Scheduler/FieldProvider.php
typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php
typo3/sysext/install/Configuration/ExtensionScanner/Php/PropertyProtectedMatcher.php
typo3/sysext/linkvalidator/Classes/Task/ValidatorTaskAdditionalFieldProvider.php
typo3/sysext/recycler/Classes/Task/CleanerFieldProvider.php
typo3/sysext/recycler/Tests/Unit/Task/CleanerFieldProviderTest.php
typo3/sysext/reports/Classes/Task/SystemStatusUpdateTaskNotificationEmailField.php
typo3/sysext/scheduler/Classes/AbstractAdditionalFieldProvider.php [new file with mode: 0644]
typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php
typo3/sysext/scheduler/Classes/Example/SleepTaskAdditionalFieldProvider.php
typo3/sysext/scheduler/Classes/Example/TestTaskAdditionalFieldProvider.php
typo3/sysext/scheduler/Classes/Task/CachingFrameworkGarbageCollectionAdditionalFieldProvider.php
typo3/sysext/scheduler/Classes/Task/Enumeration/Action.php [new file with mode: 0644]
typo3/sysext/scheduler/Classes/Task/IpAnonymizationAdditionalFieldProvider.php
typo3/sysext/scheduler/Classes/Task/OptimizeDatabaseTableAdditionalFieldProvider.php
typo3/sysext/scheduler/Classes/Task/RecyclerGarbageCollectionAdditionalFieldProvider.php
typo3/sysext/scheduler/Classes/Task/TableGarbageCollectionAdditionalFieldProvider.php

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-84387-DeprecatedMethodAndPropertyInSchedulerModuleController.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-84387-DeprecatedMethodAndPropertyInSchedulerModuleController.rst
new file mode 100644 (file)
index 0000000..048990d
--- /dev/null
@@ -0,0 +1,38 @@
+.. include:: ../../Includes.txt
+
+=================================================================================
+Deprecation: #84387 - Deprecated method and property in SchedulerModuleController
+=================================================================================
+
+See :issue:`84387`
+
+Description
+===========
+
+The property :php:`$CMD` and the method :php:`addMessage()` in the :php:`SchedulerModuleController`
+have been marked as deprecated and will be removed in TYPO3 v10.
+
+
+Impact
+======
+
+Accessing the property or calling the method will trigger a deprecation warning.
+
+
+Affected Installations
+======================
+
+Third party code which accesses the property directly or calls the method.
+
+
+Migration
+=========
+
+Instead of accessing the property :php:`SchedulerModuleController::$CMD`, the method :php:`getCurrentAction()`
+must be used which returns an instance of the :php:`TYPO3\CMS\Scheduler\Task\Enumeration\Action` enumeration.
+
+Instead of calling the method :php:`SchedulerModuleController::addMessage()`, in your additional field providers
+you can now extend :php:`TYPO3\CMS\Scheduler\AbstractAdditionalFieldProvider` which provides a method :php:`addMessage()`
+with the same API like before.
+
+.. index:: FullyScanned
index d8f34c1..407668f 100644 (file)
@@ -15,13 +15,14 @@ namespace TYPO3\CMS\Extbase\Scheduler;
  */
 
 use TYPO3\CMS\Extbase\Utility\TypeHandlingUtility;
+use TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface;
 use TYPO3\CMS\Scheduler\Controller\SchedulerModuleController;
 use TYPO3\CMS\Scheduler\Task\AbstractTask;
 
 /**
  * Field provider for Extbase CommandController Scheduler task
  */
-class FieldProvider implements \TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface
+class FieldProvider implements AdditionalFieldProviderInterface
 {
     /**
      * @var \TYPO3\CMS\Extbase\Mvc\Cli\CommandManager
index 62d751e..7169dfa 100644 (file)
@@ -2431,4 +2431,11 @@ return [
             'Deprecation-85451-ContentObjectRenderer-calcIntExplodeDeprecated.rst'
         ],
     ],
+    'TYPO3\CMS\Scheduler\Classes\Controller\SchedulerModuleController->addMessage' => [
+        'numberOfMandatoryArguments' => 1,
+        'maximumNumberOfArguments' => 2,
+        'restFiles' => [
+            'Deprecation-84387-DeprecatedMethodAndPropertyInSchedulerModuleController.rst',
+        ],
+    ],
 ];
index 5777d70..9e5d0b2 100644 (file)
@@ -637,4 +637,9 @@ return [
             'Deprecation-85196-ProtectSetupModuleController.rst'
         ],
     ],
+    'TYPO3\CMS\Scheduler\Controller\SchedulerModuleController->CMD' => [
+        'restFiles' => [
+            'Deprecation-84387-DeprecatedMethodAndPropertyInSchedulerModuleController.rst'
+        ],
+    ],
 ];
index bc8c781..f514269 100644 (file)
@@ -18,14 +18,15 @@ use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface;
+use TYPO3\CMS\Scheduler\AbstractAdditionalFieldProvider;
 use TYPO3\CMS\Scheduler\Controller\SchedulerModuleController;
 use TYPO3\CMS\Scheduler\Task\AbstractTask;
+use TYPO3\CMS\Scheduler\Task\Enumeration\Action;
 
 /**
  * This class provides Scheduler Additional Field plugin implementation
  */
-class ValidatorTaskAdditionalFieldProvider implements AdditionalFieldProviderInterface
+class ValidatorTaskAdditionalFieldProvider extends AbstractAdditionalFieldProvider
 {
     /**
      * Default language file of the extension linkvalidator
@@ -46,55 +47,59 @@ class ValidatorTaskAdditionalFieldProvider implements AdditionalFieldProviderInt
     public function getAdditionalFields(array &$taskInfo, $task, SchedulerModuleController $schedulerModule)
     {
         $additionalFields = [];
+        $currentSchedulerModuleAction = $schedulerModule->getCurrentAction();
+
         if (empty($taskInfo['configuration'])) {
-            if ($schedulerModule->CMD === 'add') {
+            if ($currentSchedulerModuleAction->equals(Action::ADD)) {
                 $taskInfo['configuration'] = $taskInfo['linkvalidator']['configuration'];
-            } elseif ($schedulerModule->CMD === 'edit') {
+            } elseif ($currentSchedulerModuleAction->equals(Action::EDIT)) {
                 $taskInfo['configuration'] = $task->getConfiguration();
             } else {
                 $taskInfo['configuration'] = $task->getConfiguration();
             }
         }
+
         if (empty($taskInfo['depth'])) {
-            if ($schedulerModule->CMD === 'add') {
+            if ($currentSchedulerModuleAction->equals(Action::ADD)) {
                 $taskInfo['depth'] = $taskInfo['linkvalidator']['depth'];
-            } elseif ($schedulerModule->CMD === 'edit') {
+            } elseif ($currentSchedulerModuleAction->equals(Action::EDIT)) {
                 $taskInfo['depth'] = $task->getDepth();
             } else {
                 $taskInfo['depth'] = $task->getDepth();
             }
         }
+
         if (empty($taskInfo['page'])) {
-            if ($schedulerModule->CMD === 'add') {
+            if ($currentSchedulerModuleAction->equals(Action::ADD)) {
                 $taskInfo['page'] = $taskInfo['linkvalidator']['page'];
-            } elseif ($schedulerModule->CMD === 'edit') {
+            } elseif ($currentSchedulerModuleAction->equals(Action::EDIT)) {
                 $taskInfo['page'] = $task->getPage();
             } else {
                 $taskInfo['page'] = $task->getPage();
             }
         }
         if (empty($taskInfo['email'])) {
-            if ($schedulerModule->CMD === 'add') {
+            if ($currentSchedulerModuleAction->equals(Action::ADD)) {
                 $taskInfo['email'] = $taskInfo['linkvalidator']['email'];
-            } elseif ($schedulerModule->CMD === 'edit') {
+            } elseif ($currentSchedulerModuleAction->equals(Action::EDIT)) {
                 $taskInfo['email'] = $task->getEmail();
             } else {
                 $taskInfo['email'] = $task->getEmail();
             }
         }
         if (empty($taskInfo['emailOnBrokenLinkOnly'])) {
-            if ($schedulerModule->CMD === 'add') {
+            if ($currentSchedulerModuleAction->equals(Action::ADD)) {
                 $taskInfo['emailOnBrokenLinkOnly'] = $taskInfo['linkvalidator']['emailOnBrokenLinkOnly'] ? $taskInfo['linkvalidator']['emailOnBrokenLinkOnly'] : 1;
-            } elseif ($schedulerModule->CMD === 'edit') {
+            } elseif ($currentSchedulerModuleAction->equals(Action::EDIT)) {
                 $taskInfo['emailOnBrokenLinkOnly'] = $task->getEmailOnBrokenLinkOnly();
             } else {
                 $taskInfo['emailOnBrokenLinkOnly'] = $task->getEmailOnBrokenLinkOnly();
             }
         }
         if (empty($taskInfo['emailTemplateFile'])) {
-            if ($schedulerModule->CMD === 'add') {
+            if ($currentSchedulerModuleAction->equals(Action::ADD)) {
                 $taskInfo['emailTemplateFile'] = $taskInfo['linkvalidator']['emailTemplateFile'] ? $taskInfo['linkvalidator']['emailTemplateFile'] : 'EXT:linkvalidator/Resources/Private/Templates/mailtemplate.html';
-            } elseif ($schedulerModule->CMD === 'edit') {
+            } elseif ($currentSchedulerModuleAction->equals(Action::EDIT)) {
                 $taskInfo['emailTemplateFile'] = $task->getEmailTemplateFile();
             } else {
                 $taskInfo['emailTemplateFile'] = $task->getEmailTemplateFile();
@@ -233,7 +238,7 @@ class ValidatorTaskAdditionalFieldProvider implements AdditionalFieldProviderInt
             foreach ($emailList as $emailAdd) {
                 if (!GeneralUtility::validEmail($emailAdd)) {
                     $isValid = false;
-                    $schedulerModule->addMessage(
+                    $this->addMessage(
                         $lang->sL($this->languageFile . ':tasks.validate.invalidEmail'),
                         FlashMessage::ERROR
                     );
@@ -244,14 +249,14 @@ class ValidatorTaskAdditionalFieldProvider implements AdditionalFieldProviderInt
         $row = BackendUtility::getRecord('pages', (int)$submittedData['linkvalidator']['page'], '*', '', false);
         if (empty($row)) {
             $isValid = false;
-            $schedulerModule->addMessage(
+            $this->addMessage(
                 $lang->sL($this->languageFile . ':tasks.validate.invalidPage'),
                 FlashMessage::ERROR
             );
         }
         if ($submittedData['linkvalidator']['depth'] < 0) {
             $isValid = false;
-            $schedulerModule->addMessage(
+            $this->addMessage(
                 $lang->sL($this->languageFile . ':tasks.validate.invalidDepth'),
                 FlashMessage::ERROR
             );
index 38a59e0..042d6ab 100644 (file)
@@ -15,14 +15,16 @@ namespace TYPO3\CMS\Recycler\Task;
  */
 
 use TYPO3\CMS\Core\Messaging\FlashMessage;
+use TYPO3\CMS\Scheduler\AbstractAdditionalFieldProvider;
 use TYPO3\CMS\Scheduler\Controller\SchedulerModuleController;
 use TYPO3\CMS\Scheduler\Task\AbstractTask;
+use TYPO3\CMS\Scheduler\Task\Enumeration\Action;
 
 /**
  * A task that should be run regularly that deletes
  * datasets flagged as "deleted" from the DB.
  */
-class CleanerFieldProvider implements \TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface
+class CleanerFieldProvider extends AbstractAdditionalFieldProvider
 {
     /**
      * Gets additional fields to render in the form to add/edit a task
@@ -34,7 +36,9 @@ class CleanerFieldProvider implements \TYPO3\CMS\Scheduler\AdditionalFieldProvid
      */
     public function getAdditionalFields(array &$taskInfo, $task, SchedulerModuleController $schedulerModule)
     {
-        if ($schedulerModule->CMD === 'edit') {
+        $currentSchedulerModuleAction = $schedulerModule->getCurrentAction();
+
+        if ($currentSchedulerModuleAction->equals(Action::EDIT)) {
             $taskInfo['RecyclerCleanerTCA'] = $task->getTcaTables();
             $taskInfo['RecyclerCleanerPeriod'] = $task->getPeriod();
         }
@@ -94,8 +98,8 @@ class CleanerFieldProvider implements \TYPO3\CMS\Scheduler\AdditionalFieldProvid
      */
     public function validateAdditionalFields(array &$submittedData, SchedulerModuleController $schedulerModule)
     {
-        $validPeriod = $this->validateAdditionalFieldPeriod($submittedData['RecyclerCleanerPeriod'], $schedulerModule);
-        $validTca = $this->validateAdditionalFieldTca($submittedData['RecyclerCleanerTCA'], $schedulerModule);
+        $validPeriod = $this->validateAdditionalFieldPeriod($submittedData['RecyclerCleanerPeriod']);
+        $validTca = $this->validateAdditionalFieldTca($submittedData['RecyclerCleanerTCA']);
 
         return $validPeriod && $validTca;
     }
@@ -104,27 +108,25 @@ class CleanerFieldProvider implements \TYPO3\CMS\Scheduler\AdditionalFieldProvid
      * Validates the selected Tables
      *
      * @param array $tca The given TCA-tables as array
-     * @param SchedulerModuleController $schedulerModule Reference to the scheduler backend module
      * @return bool TRUE if validation was ok, FALSE otherwise
      */
-    protected function validateAdditionalFieldTca($tca, SchedulerModuleController $schedulerModule)
+    protected function validateAdditionalFieldTca($tca)
     {
-        return $this->checkTcaIsNotEmpty($tca, $schedulerModule) && $this->checkTcaIsValid($tca, $schedulerModule);
+        return $this->checkTcaIsNotEmpty($tca) && $this->checkTcaIsValid($tca);
     }
 
     /**
      * Checks if the array is empty
      *
      * @param array $tca The given TCA-tables as array
-     * @param SchedulerModuleController $schedulerModule Reference to the scheduler backend module
      * @return bool TRUE if validation was ok, FALSE otherwise
      */
-    protected function checkTcaIsNotEmpty($tca, SchedulerModuleController $schedulerModule)
+    protected function checkTcaIsNotEmpty($tca)
     {
         if (is_array($tca) && !empty($tca)) {
             $validTca = true;
         } else {
-            $schedulerModule->addMessage(
+            $this->addMessage(
                 $this->getLanguageService()->sL('LLL:EXT:recycler/Resources/Private/Language/locallang_tasks.xlf:cleanerTaskErrorTCAempty'),
                 FlashMessage::ERROR
             );
@@ -138,16 +140,15 @@ class CleanerFieldProvider implements \TYPO3\CMS\Scheduler\AdditionalFieldProvid
      * Checks if the given tables are in the TCA
      *
      * @param array $tca The given TCA-tables as array
-     * @param SchedulerModuleController $schedulerModule Reference to the scheduler backend module
      * @return bool TRUE if validation was ok, FALSE otherwise
      */
-    protected function checkTcaIsValid(array $tca, SchedulerModuleController $schedulerModule)
+    protected function checkTcaIsValid(array $tca)
     {
         $checkTca = false;
         foreach ($tca as $tcaTable) {
             if (!isset($GLOBALS['TCA'][$tcaTable])) {
                 $checkTca = false;
-                $schedulerModule->addMessage(
+                $this->addMessage(
                     sprintf($this->getLanguageService()->sL('LLL:EXT:recycler/Resources/Private/Language/locallang_tasks.xlf:cleanerTaskErrorTCANotSet'), $tcaTable),
                     FlashMessage::ERROR
                 );
@@ -163,15 +164,14 @@ class CleanerFieldProvider implements \TYPO3\CMS\Scheduler\AdditionalFieldProvid
      * Validates the input of period
      *
      * @param int $period The given period as integer
-     * @param SchedulerModuleController $schedulerModule Reference to the scheduler backend module
      * @return bool TRUE if validation was ok, FALSE otherwise
      */
-    protected function validateAdditionalFieldPeriod($period, SchedulerModuleController $schedulerModule)
+    protected function validateAdditionalFieldPeriod($period)
     {
         if (!empty($period) && filter_var($period, FILTER_VALIDATE_INT) !== false) {
             $validPeriod = true;
         } else {
-            $schedulerModule->addMessage(
+            $this->addMessage(
                 $this->getLanguageService()->sL('LLL:EXT:recycler/Resources/Private/Language/locallang_tasks.xlf:cleanerTaskErrorPeriod'),
                 FlashMessage::ERROR
             );
@@ -192,7 +192,7 @@ class CleanerFieldProvider implements \TYPO3\CMS\Scheduler\AdditionalFieldProvid
     {
         if (!$task instanceof CleanerTask) {
             throw new \InvalidArgumentException(
-                'Expected a task of type \TYPO3\CMS\Recycler\Task\CleanerTask, but got ' . get_class($task),
+                'Expected a task of type ' . CleanerTask::class . ', but got ' . get_class($task),
                 1329219449
             );
         }
index 8e131cf..73997cc 100644 (file)
@@ -41,7 +41,7 @@ class CleanerFieldProviderTest extends \TYPO3\TestingFramework\Core\Unit\UnitTes
             ->getMock();
         $languageServiceMock->expects($this->any())->method('sL')->will($this->returnValue('titleTest'));
         $this->subject = $this->getMockBuilder(CleanerFieldProvider::class)
-            ->setMethods(['getLanguageService'])
+            ->setMethods(['getLanguageService', 'addMessage'])
             ->getMock();
         $this->subject->expects($this->any())->method('getLanguageService')->willReturn($languageServiceMock);
     }
@@ -95,8 +95,8 @@ class CleanerFieldProviderTest extends \TYPO3\TestingFramework\Core\Unit\UnitTes
             'RecyclerCleanerTCA' => ['pages']
         ];
 
-        $scheduleModuleControllerMock = $this->getScheduleModuleControllerMock(['addMessage']);
-        $scheduleModuleControllerMock->expects($this->atLeastOnce())
+        $scheduleModuleControllerMock = $this->getScheduleModuleControllerMock();
+        $this->subject->expects($this->atLeastOnce())
             ->method('addMessage')
             ->with($this->equalTo('titleTest'), FlashMessage::ERROR);
 
@@ -128,7 +128,7 @@ class CleanerFieldProviderTest extends \TYPO3\TestingFramework\Core\Unit\UnitTes
             'RecyclerCleanerTCA' => $table
         ];
 
-        $this->subject->validateAdditionalFields($submittedData, $this->getScheduleModuleControllerMock(['addMessage']));
+        $this->subject->validateAdditionalFields($submittedData, $this->getScheduleModuleControllerMock());
     }
 
     /**
index 8ec7d86..a06bfe9 100644 (file)
@@ -17,15 +17,16 @@ namespace TYPO3\CMS\Reports\Task;
 use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface;
+use TYPO3\CMS\Scheduler\AbstractAdditionalFieldProvider;
 use TYPO3\CMS\Scheduler\Controller\SchedulerModuleController;
 use TYPO3\CMS\Scheduler\Task\AbstractTask;
+use TYPO3\CMS\Scheduler\Task\Enumeration\Action;
 
 /**
  * Additional field to set the notification email address(es) for system health
  * issue notifications.
  */
-class SystemStatusUpdateTaskNotificationEmailField implements AdditionalFieldProviderInterface
+class SystemStatusUpdateTaskNotificationEmailField extends AbstractAdditionalFieldProvider
 {
     /**
      * Additional fields
@@ -51,7 +52,9 @@ class SystemStatusUpdateTaskNotificationEmailField implements AdditionalFieldPro
      */
     public function getAdditionalFields(array &$taskInfo, $task, SchedulerModuleController $schedulerModule)
     {
-        if ($schedulerModule->CMD === 'edit') {
+        $currentSchedulerModuleAction = $schedulerModule->getCurrentAction();
+
+        if ($currentSchedulerModuleAction->equals(Action::EDIT)) {
             $taskInfo[$this->fieldPrefix . 'NotificationEmail'] = $task->getNotificationEmail();
             $taskInfo[$this->fieldPrefix . 'NotificationAll'] = $task->getNotificationAll();
         }
@@ -100,8 +103,8 @@ class SystemStatusUpdateTaskNotificationEmailField implements AdditionalFieldPro
                 break;
             }
         }
-        if (empty($submittedData[$this->fieldPrefix . 'NotificationEmail']) || !$validInput) {
-            $schedulerModule->addMessage($this->getLanguageService()->sL('LLL:EXT:reports/Resources/Private/Language/locallang_reports.xlf:status_updateTaskField_notificationEmails_invalid'), FlashMessage::ERROR);
+        if (!$validInput || empty($submittedData[$this->fieldPrefix . 'NotificationEmail'])) {
+            $this->addMessage($this->getLanguageService()->sL('LLL:EXT:reports/Resources/Private/Language/locallang_reports.xlf:status_updateTaskField_notificationEmails_invalid'), FlashMessage::ERROR);
             $validInput = false;
         }
         return $validInput;
@@ -112,6 +115,7 @@ class SystemStatusUpdateTaskNotificationEmailField implements AdditionalFieldPro
      *
      * @param array $submittedData An array containing the data submitted by the add/edit task form
      * @param AbstractTask $task Reference to the scheduler backend module
+     * @throws \InvalidArgumentException
      */
     public function saveAdditionalFields(array $submittedData, AbstractTask $task)
     {
diff --git a/typo3/sysext/scheduler/Classes/AbstractAdditionalFieldProvider.php b/typo3/sysext/scheduler/Classes/AbstractAdditionalFieldProvider.php
new file mode 100644 (file)
index 0000000..83a7cf5
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+declare(strict_types = 1);
+namespace TYPO3\CMS\Scheduler;
+
+/*
+ * 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 TYPO3\CMS\Core\Messaging\FlashMessage;
+use TYPO3\CMS\Core\Messaging\FlashMessageService;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
+/**
+ * Base class for providers of additional fields
+ */
+abstract class AbstractAdditionalFieldProvider implements AdditionalFieldProviderInterface
+{
+    /**
+     * Add a flash message
+     *
+     * @param string $message the flash message content
+     * @param int $severity the flash message severity
+     */
+    protected function addMessage(string $message, int $severity = FlashMessage::OK): void
+    {
+        $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $message, '', $severity);
+        $service = GeneralUtility::makeInstance(FlashMessageService::class);
+        $queue = $service->getMessageQueueByIdentifier();
+        $queue->enqueue($flashMessage);
+    }
+}
index 6b6e60c..2868091 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+declare(strict_types = 1);
 namespace TYPO3\CMS\Scheduler\Controller;
 
 /*
@@ -16,9 +17,13 @@ namespace TYPO3\CMS\Scheduler\Controller;
 
 use Psr\Http\Message\ResponseInterface;
 use Psr\Http\Message\ServerRequestInterface;
+use TYPO3\CMS\Backend\Routing\UriBuilder;
 use TYPO3\CMS\Backend\Template\Components\ButtonBar;
 use TYPO3\CMS\Backend\Template\ModuleTemplate;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
+use TYPO3\CMS\Core\Compatibility\PublicMethodDeprecationTrait;
+use TYPO3\CMS\Core\Compatibility\PublicPropertyDeprecationTrait;
 use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Http\HtmlResponse;
@@ -38,12 +43,30 @@ use TYPO3\CMS\Scheduler\CronCommand\NormalizeCommand;
 use TYPO3\CMS\Scheduler\ProgressProviderInterface;
 use TYPO3\CMS\Scheduler\Scheduler;
 use TYPO3\CMS\Scheduler\Task\AbstractTask;
+use TYPO3\CMS\Scheduler\Task\Enumeration\Action;
 
 /**
  * Module 'TYPO3 Scheduler administration module' for the 'scheduler' extension.
  */
 class SchedulerModuleController
 {
+    use PublicMethodDeprecationTrait;
+    use PublicPropertyDeprecationTrait;
+
+    /**
+     * @var array
+     */
+    private $deprecatedPublicMethods = [
+        'addMessage' => 'Using SchedulerModuleController::addMessage() is deprecated and will not be possible anymore in TYPO3 v10.',
+    ];
+
+    /**
+     * @var array
+     */
+    private $deprecatedPublicProperties = [
+        'CMD' => 'Using SchedulerModuleController::$CMD is deprecated and will not be possible anymore in TYPO3 v10. Use SchedulerModuleController::getCurrentAction() instead.',
+    ];
+
     /**
      * Array containing submitted data when editing or adding a task
      *
@@ -99,15 +122,18 @@ class SchedulerModuleController
     /**
      * The value of GET/POST var, 'CMD'
      *
-     * @see init()
      * @var mixed
      */
-    public $CMD;
+    protected $CMD;
+
+    /**
+     * @var Action
+     */
+    protected $action;
 
     /**
      * The module menu items array. Each key represents a key for which values can range between the items in the array of that key.
      *
-     * @see init()
      * @var array
      */
     protected $MOD_MENU = [
@@ -133,8 +159,7 @@ class SchedulerModuleController
         $this->view = GeneralUtility::makeInstance(StandaloneView::class);
         $this->view->getRequest()->setControllerExtensionName('scheduler');
         $this->view->setPartialRootPaths([ExtensionManagementUtility::extPath('scheduler') . 'Resources/Private/Partials/Backend/SchedulerModule/']);
-        /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
-        $uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
+        $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
         $this->moduleUri = (string)$uriBuilder->buildUriFromRoute('system_txschedulerM1');
         $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
         $this->scheduler = GeneralUtility::makeInstance(Scheduler::class);
@@ -145,14 +170,16 @@ class SchedulerModuleController
 
     /**
      * Injects the request object for the current request or subrequest
-     * Simply calls main() and init() and outputs the content
      *
      * @param ServerRequestInterface $request the current request
      * @return ResponseInterface the response with the content
      */
     public function mainAction(ServerRequestInterface $request): ResponseInterface
     {
-        $this->CMD = GeneralUtility::_GP('CMD');
+        $parsedBody = $request->getParsedBody();
+        $queryParams = $request->getQueryParams();
+
+        $this->setCurrentAction(Action::cast($parsedBody['CMD'] ?? $queryParams['CMD'] ?? null));
         $this->MOD_MENU = [
             'function' => [
                 'scheduler' => $this->getLanguageService()->getLL('function.scheduler'),
@@ -160,14 +187,16 @@ class SchedulerModuleController
                 'info' => $this->getLanguageService()->getLL('function.info')
             ]
         ];
-        $this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP('SET'), 'system_txschedulerM1', '', '', '');
+        $settings = $parsedBody['SET'] ?? $queryParams['SET'] ?? null;
+        $this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, $settings, 'system_txschedulerM1', '', '', '');
 
         // Set the form
         $content = '<form name="tx_scheduler_form" id="tx_scheduler_form" method="post" action="">';
 
         // Prepare main content
         $content .= '<h1>' . $this->getLanguageService()->getLL('function.' . $this->MOD_SETTINGS['function']) . '</h1>';
-        $content .= $this->getModuleContent();
+        $previousCMD = Action::cast($parsedBody['previousCMD'] ?? $queryParams['previousCMD'] ?? null);
+        $content .= $this->getModuleContent($previousCMD);
         $content .= '<div id="extraFieldsSection"></div></form><div id="extraFieldsHidden"></div>';
 
         $this->getButtons();
@@ -178,14 +207,24 @@ class SchedulerModuleController
     }
 
     /**
+     * Get the current action
+     *
+     * @return Action
+     */
+    public function getCurrentAction(): Action
+    {
+        return $this->action;
+    }
+
+    /**
      * Generates the action menu
      */
-    protected function getModuleMenu()
+    protected function getModuleMenu(): void
     {
         $menu = $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
         $menu->setIdentifier('SchedulerJumpMenu');
-        /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
-        $uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
+        /** @var UriBuilder $uriBuilder */
+        $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
         foreach ($this->MOD_MENU['function'] as $controller => $title) {
             $item = $menu
                 ->makeMenuItem()
@@ -212,9 +251,10 @@ class SchedulerModuleController
     /**
      * Generate the module's content
      *
+     * @param Action $previousAction
      * @return string HTML of the module's main content
      */
-    protected function getModuleContent()
+    protected function getModuleContent(Action $previousAction): string
     {
         $content = '';
         $sectionTitle = '';
@@ -222,30 +262,31 @@ class SchedulerModuleController
         $this->submittedData = GeneralUtility::_GPmerged('tx_scheduler');
         $this->submittedData['uid'] = (int)$this->submittedData['uid'];
         // If a save command was submitted, handle saving now
-        if ($this->CMD === 'save' || $this->CMD === 'saveclose' || $this->CMD === 'savenew') {
-            $previousCMD = GeneralUtility::_GP('previousCMD');
+        if (in_array((string)$this->getCurrentAction(), [Action::SAVE, Action::SAVE_CLOSE, Action::SAVE_NEW], true)) {
             // First check the submitted data
             $result = $this->preprocessData();
+
             // If result is ok, proceed with saving
             if ($result) {
                 $this->saveTask();
-                if ($this->CMD === 'saveclose') {
-                    // Unset command, so that default screen gets displayed
-                    unset($this->CMD);
-                } elseif ($this->CMD === 'save') {
+
+                if ($this->action->equals(Action::SAVE_CLOSE)) {
+                    // Display default screen
+                    $this->setCurrentAction(Action::cast(Action::LIST));
+                } elseif ($this->action->equals(Action::SAVE)) {
                     // After saving a "add form", return to edit
-                    $this->CMD = 'edit';
-                } elseif ($this->CMD === 'savenew') {
+                    $this->setCurrentAction(Action::cast(Action::EDIT));
+                } elseif ($this->action->equals(Action::SAVE_NEW)) {
                     // Unset submitted data, so that empty form gets displayed
                     unset($this->submittedData);
                     // After saving a "add/edit form", return to add
-                    $this->CMD = 'add';
+                    $this->setCurrentAction(Action::cast(Action::ADD));
                 } else {
                     // Return to edit form
-                    $this->CMD = $previousCMD;
+                    $this->setCurrentAction($previousAction);
                 }
             } else {
-                $this->CMD = $previousCMD;
+                $this->setCurrentAction($previousAction);
             }
         }
 
@@ -254,13 +295,13 @@ class SchedulerModuleController
             case 'scheduler':
                 $this->executeTasks();
 
-                switch ($this->CMD) {
-                    case 'add':
-                    case 'edit':
+                switch ((string)$this->getCurrentAction()) {
+                    case Action::ADD:
+                    case Action::EDIT:
                         try {
                             // Try adding or editing
                             $content .= $this->editTaskAction();
-                            $sectionTitle = $this->getLanguageService()->getLL('action.' . $this->CMD);
+                            $sectionTitle = $this->getLanguageService()->getLL('action.' . $this->getCurrentAction());
                         } catch (\Exception $e) {
                             if ($e->getCode() === 1305100019) {
                                 // Invalid controller class name exception
@@ -273,25 +314,23 @@ class SchedulerModuleController
                             $content .= $this->listTasksAction();
                         }
                         break;
-                    case 'delete':
+                    case Action::DELETE:
                         $this->deleteTask();
                         $content .= $this->listTasksAction();
                         break;
-                    case 'stop':
+                    case Action::STOP:
                         $this->stopTask();
                         $content .= $this->listTasksAction();
                         break;
-                    case 'toggleHidden':
+                    case Action::TOGGLE_HIDDEN:
                         $this->toggleDisableAction();
                         $content .= $this->listTasksAction();
                         break;
-                    case 'setNextExecutionTime':
+                    case Action::SET_NEXT_EXECUTION_TIME:
                         $this->setNextExecutionTimeAction();
                         $content .= $this->listTasksAction();
                         break;
-                    case 'list':
-
-                    default:
+                    case Action::LIST:
                         $content .= $this->listTasksAction();
                 }
                 break;
@@ -317,7 +356,7 @@ class SchedulerModuleController
      *
      * @return string Further information
      */
-    protected function checkScreenAction()
+    protected function checkScreenAction(): string
     {
         $this->view->setTemplatePathAndFilename($this->backendTemplatePath . 'CheckScreen.html');
 
@@ -378,7 +417,7 @@ class SchedulerModuleController
      *
      * @return string html
      */
-    protected function infoScreenAction()
+    protected function infoScreenAction(): string
     {
         $registeredClasses = $this->getRegisteredClasses();
         // No classes available, display information message
@@ -396,7 +435,7 @@ class SchedulerModuleController
     /**
      * Delete a task from the execution queue
      */
-    protected function deleteTask()
+    protected function deleteTask(): void
     {
         try {
             // Try to fetch the task and delete it
@@ -435,7 +474,7 @@ class SchedulerModuleController
      * all executions.
      * @todo find a way to really kill the running task
      */
-    protected function stopTask()
+    protected function stopTask(): void
     {
         try {
             // Try to fetch the task and stop it
@@ -461,7 +500,7 @@ class SchedulerModuleController
     /**
      * Toggles the disabled state of the submitted task
      */
-    protected function toggleDisableAction()
+    protected function toggleDisableAction(): void
     {
         $task = $this->scheduler->fetchTask($this->submittedData['uid']);
         $task->setDisabled(!$task->isDisabled());
@@ -476,7 +515,7 @@ class SchedulerModuleController
     /**
      * Sets the next execution time of the submitted task to now
      */
-    protected function setNextExecutionTimeAction()
+    protected function setNextExecutionTimeAction(): void
     {
         $task = $this->scheduler->fetchTask($this->submittedData['uid']);
         $task->setRunOnNextCronJob(true);
@@ -488,7 +527,7 @@ class SchedulerModuleController
      *
      * @return string HTML form to add or edit a task
      */
-    protected function editTaskAction()
+    protected function editTaskAction(): string
     {
         $this->view->setTemplatePathAndFilename($this->backendTemplatePath . 'EditTask.html');
 
@@ -608,8 +647,8 @@ class SchedulerModuleController
         ');
 
         // Start rendering the add/edit form
-        $this->view->assign('uid', htmlspecialchars($this->submittedData['uid']));
-        $this->view->assign('cmd', htmlspecialchars($this->CMD));
+        $this->view->assign('uid', htmlspecialchars((string)$this->submittedData['uid']));
+        $this->view->assign('cmd', htmlspecialchars((string)$this->getCurrentAction()));
         $this->view->assign('csh', $this->cshKey);
         $this->view->assign('lang', 'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:');
 
@@ -711,11 +750,10 @@ class SchedulerModuleController
      * @param array $fieldInfo The array with the field info, contains the page title shown beside the button
      * @return string HTML code for the browse button
      */
-    protected function getBrowseButton($fieldID, array $fieldInfo)
+    protected function getBrowseButton($fieldID, array $fieldInfo): string
     {
         if (isset($fieldInfo['browser']) && ($fieldInfo['browser'] === 'page')) {
-            /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
-            $uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
+            $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
             $url = (string)$uriBuilder->buildUriFromRoute(
                 'wizard_element_browser',
                 ['mode' => 'db', 'bparams' => $fieldID . '|||pages|']
@@ -737,7 +775,7 @@ class SchedulerModuleController
     /**
      * Execute all selected tasks
      */
-    protected function executeTasks()
+    protected function executeTasks(): void
     {
         // Continue if some elements have been chosen for execution
         if (isset($this->submittedData['execute']) && !empty($this->submittedData['execute'])) {
@@ -776,7 +814,7 @@ class SchedulerModuleController
             // Record the run in the system registry
             $this->scheduler->recordLastRun('manual');
             // Make sure to switch to list view after execution
-            $this->CMD = 'list';
+            $this->setCurrentAction(Action::cast(Action::LIST));
         }
     }
 
@@ -785,7 +823,7 @@ class SchedulerModuleController
      *
      * @return string Table of pending tasks
      */
-    protected function listTasksAction()
+    protected function listTasksAction(): string
     {
         $this->view->setTemplatePathAndFilename($this->backendTemplatePath . 'ListTasks.html');
 
@@ -997,7 +1035,7 @@ class SchedulerModuleController
      * @param array $labels
      * @return string
      */
-    protected function makeStatusLabel(array $labels)
+    protected function makeStatusLabel(array $labels): string
     {
         $htmlLabels = [];
         foreach ($labels as $label) {
@@ -1013,7 +1051,7 @@ class SchedulerModuleController
     /**
      * Saves a task specified in the backend form to the database
      */
-    protected function saveTask()
+    protected function saveTask(): void
     {
         // If a task is being edited fetch old task data
         if (!empty($this->submittedData['uid'])) {
@@ -1230,7 +1268,7 @@ class SchedulerModuleController
      * @param string $message The message itself
      * @param int $severity Message level (according to FlashMessage class constants)
      */
-    public function addMessage($message, $severity = FlashMessage::OK)
+    protected function addMessage($message, $severity = FlashMessage::OK)
     {
         $this->moduleTemplate->addFlashMessage($message, '', $severity);
     }
@@ -1248,7 +1286,7 @@ class SchedulerModuleController
      *
      * @return array List of registered classes
      */
-    protected function getRegisteredClasses()
+    protected function getRegisteredClasses(): array
     {
         $list = [];
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'] ?? [] as $class => $registrationInformation) {
@@ -1269,7 +1307,7 @@ class SchedulerModuleController
      *
      * @return array List of registered groups
      */
-    protected function getRegisteredTaskGroups()
+    protected function getRegisteredTaskGroups(): array
     {
         $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
             ->getQueryBuilderForTable('tx_scheduler_task_group');
@@ -1285,7 +1323,7 @@ class SchedulerModuleController
     /**
      * Create the panel of buttons for submitting the form or otherwise perform operations.
      */
-    protected function getButtons()
+    protected function getButtons(): void
     {
         $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
         // CSH
@@ -1293,8 +1331,9 @@ class SchedulerModuleController
             ->setModuleName('_MOD_system_txschedulerM1')
             ->setFieldName('');
         $buttonBar->addButton($helpButton);
+
         // Add and Reload
-        if (empty($this->CMD) || $this->CMD === 'list' || $this->CMD === 'delete' || $this->CMD === 'stop' || $this->CMD === 'toggleHidden' || $this->CMD === 'setNextExecutionTime') {
+        if (in_array((string)$this->getCurrentAction(), [Action::LIST, Action::DELETE, Action::STOP, Action::TOGGLE_HIDDEN, Action::SET_NEXT_EXECUTION_TIME], true)) {
             $reloadButton = $buttonBar->makeLinkButton()
                 ->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.reload'))
                 ->setIcon($this->moduleTemplate->getIconFactory()->getIcon('actions-refresh', Icon::SIZE_SMALL))
@@ -1304,12 +1343,13 @@ class SchedulerModuleController
                 $addButton = $buttonBar->makeLinkButton()
                     ->setTitle($this->getLanguageService()->getLL('action.add'))
                     ->setIcon($this->moduleTemplate->getIconFactory()->getIcon('actions-add', Icon::SIZE_SMALL))
-                    ->setHref($this->moduleUri . '&CMD=add');
+                    ->setHref($this->moduleUri . '&CMD=' . Action::ADD);
                 $buttonBar->addButton($addButton, ButtonBar::BUTTON_POSITION_LEFT, 2);
             }
         }
+
         // Close and Save
-        if ($this->CMD === 'add' || $this->CMD === 'edit') {
+        if (in_array((string)$this->getCurrentAction(), [Action::ADD, Action::EDIT], true)) {
             // Close
             $closeButton = $buttonBar->makeLinkButton()
                 ->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:cancel'))
@@ -1321,37 +1361,39 @@ class SchedulerModuleController
             $saveButtonDropdown = $buttonBar->makeSplitButton();
             $saveButton = $buttonBar->makeInputButton()
                 ->setName('CMD')
-                ->setValue('save')
+                ->setValue(Action::SAVE)
                 ->setForm('tx_scheduler_form')
                 ->setIcon($this->moduleTemplate->getIconFactory()->getIcon('actions-document-save', Icon::SIZE_SMALL))
                 ->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:save'));
             $saveButtonDropdown->addItem($saveButton);
             $saveAndNewButton = $buttonBar->makeInputButton()
                 ->setName('CMD')
-                ->setValue('savenew')
+                ->setValue(Action::SAVE_NEW)
                 ->setForm('tx_scheduler_form')
                 ->setIcon($this->moduleTemplate->getIconFactory()->getIcon('actions-document-save-new', Icon::SIZE_SMALL))
                 ->setTitle($this->getLanguageService()->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.saveAndCreateNewTask'));
             $saveButtonDropdown->addItem($saveAndNewButton);
             $saveAndCloseButton = $buttonBar->makeInputButton()
                 ->setName('CMD')
-                ->setValue('saveclose')
+                ->setValue(Action::SAVE_CLOSE)
                 ->setForm('tx_scheduler_form')
                 ->setIcon($this->moduleTemplate->getIconFactory()->getIcon('actions-document-save-close', Icon::SIZE_SMALL))
                 ->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:saveAndClose'));
             $saveButtonDropdown->addItem($saveAndCloseButton);
             $buttonBar->addButton($saveButtonDropdown, ButtonBar::BUTTON_POSITION_LEFT, 3);
         }
+
         // Edit
-        if ($this->CMD === 'edit') {
+        if ($this->getCurrentAction()->equals(Action::EDIT)) {
             $deleteButton = $buttonBar->makeInputButton()
                 ->setName('CMD')
-                ->setValue('delete')
+                ->setValue(Action::DELETE)
                 ->setForm('tx_scheduler_form')
                 ->setIcon($this->moduleTemplate->getIconFactory()->getIcon('actions-edit-delete', Icon::SIZE_SMALL))
                 ->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:delete'));
             $buttonBar->addButton($deleteButton, ButtonBar::BUTTON_POSITION_LEFT, 4);
         }
+
         // Shortcut
         $shortcutButton = $buttonBar->makeShortcutButton()
             ->setModuleName('system_txschedulerM1')
@@ -1361,9 +1403,21 @@ class SchedulerModuleController
     }
 
     /**
+     * Set the current action
+     *
+     * @param Action $action
+     */
+    protected function setCurrentAction(Action $action): void
+    {
+        $this->action = $action;
+        // @deprecated since TYPO3 v9, will be removed with TYPO3 v10
+        $this->CMD = (string)$action;
+    }
+
+    /**
      * @return string
      */
-    protected function getServerTime()
+    protected function getServerTime(): string
     {
         $dateFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] . ' ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'] . ' T (e';
         return date($dateFormat) . ', GMT ' . date('P') . ')';
@@ -1373,7 +1427,7 @@ class SchedulerModuleController
      * Returns the Language Service
      * @return LanguageService
      */
-    protected function getLanguageService()
+    protected function getLanguageService(): LanguageService
     {
         return $GLOBALS['LANG'];
     }
@@ -1383,7 +1437,7 @@ class SchedulerModuleController
      *
      * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
      */
-    protected function getBackendUser()
+    protected function getBackendUser(): BackendUserAuthentication
     {
         return $GLOBALS['BE_USER'];
     }
@@ -1391,7 +1445,7 @@ class SchedulerModuleController
     /**
      * @return PageRenderer
      */
-    protected function getPageRenderer()
+    protected function getPageRenderer(): PageRenderer
     {
         return GeneralUtility::makeInstance(PageRenderer::class);
     }
index 5eb3f20..03f07f0 100644 (file)
@@ -14,12 +14,16 @@ namespace TYPO3\CMS\Scheduler\Example;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Messaging\FlashMessage;
+use TYPO3\CMS\Scheduler\AbstractAdditionalFieldProvider;
+use TYPO3\CMS\Scheduler\Controller\SchedulerModuleController;
 use TYPO3\CMS\Scheduler\Task\AbstractTask;
+use TYPO3\CMS\Scheduler\Task\Enumeration\Action;
 
 /**
  * Additional fields provider class for usage with the Scheduler's sleep task
  */
-class SleepTaskAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface
+class SleepTaskAdditionalFieldProvider extends AbstractAdditionalFieldProvider
 {
     /**
      * This method is used to define new fields for adding or editing a task
@@ -27,17 +31,19 @@ class SleepTaskAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\Additiona
      *
      * @param array $taskInfo Reference to the array containing the info used in the add/edit form
      * @param AbstractTask|null $task When editing, reference to the current task. NULL when adding.
-     * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module)
+     * @param SchedulerModuleController $schedulerModule Reference to the calling object (Scheduler's BE module)
      * @return array Array containing all the information pertaining to the additional fields
      */
-    public function getAdditionalFields(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
+    public function getAdditionalFields(array &$taskInfo, $task, SchedulerModuleController $schedulerModule)
     {
+        $currentSchedulerModuleAction = $schedulerModule->getCurrentAction();
+
         // Initialize extra field value
         if (empty($taskInfo['sleepTime'])) {
-            if ($parentObject->CMD === 'add') {
+            if ($currentSchedulerModuleAction->equals(Action::ADD)) {
                 // In case of new task and if field is empty, set default sleep time
                 $taskInfo['sleepTime'] = 30;
-            } elseif ($parentObject->CMD === 'edit') {
+            } elseif ($currentSchedulerModuleAction->equals(Action::EDIT)) {
                 // In case of edit, set to internal value if no data was submitted already
                 $taskInfo['sleepTime'] = $task->sleepTime;
             } else {
@@ -63,14 +69,14 @@ class SleepTaskAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\Additiona
      * If the task class is not relevant, the method is expected to return TRUE
      *
      * @param array $submittedData Reference to the array containing the data submitted by the user
-     * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module)
+     * @param SchedulerModuleController $schedulerModule Reference to the calling object (Scheduler's BE module)
      * @return bool TRUE if validation was ok (or selected class is not relevant), FALSE otherwise
      */
-    public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
+    public function validateAdditionalFields(array &$submittedData, SchedulerModuleController $schedulerModule)
     {
         $submittedData['sleepTime'] = (int)$submittedData['sleepTime'];
         if ($submittedData['sleepTime'] < 0) {
-            $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.invalidSleepTime'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
+            $this->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.invalidSleepTime'), FlashMessage::ERROR);
             $result = false;
         } else {
             $result = true;
@@ -83,9 +89,9 @@ class SleepTaskAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\Additiona
      * if the task class matches
      *
      * @param array $submittedData Array containing the data submitted by the user
-     * @param \TYPO3\CMS\Scheduler\Task\AbstractTask $task Reference to the current task object
+     * @param AbstractTask $task Reference to the current task object
      */
-    public function saveAdditionalFields(array $submittedData, \TYPO3\CMS\Scheduler\Task\AbstractTask $task)
+    public function saveAdditionalFields(array $submittedData, AbstractTask $task)
     {
         $task->sleepTime = $submittedData['sleepTime'];
     }
index bdc9c74..8cbe69e 100644 (file)
@@ -14,12 +14,16 @@ namespace TYPO3\CMS\Scheduler\Example;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Messaging\FlashMessage;
+use TYPO3\CMS\Scheduler\AbstractAdditionalFieldProvider;
+use TYPO3\CMS\Scheduler\Controller\SchedulerModuleController;
 use TYPO3\CMS\Scheduler\Task\AbstractTask;
+use TYPO3\CMS\Scheduler\Task\Enumeration\Action;
 
 /**
  * Additional fields provider class for usage with the Scheduler's test task
  */
-class TestTaskAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface
+class TestTaskAdditionalFieldProvider extends AbstractAdditionalFieldProvider
 {
     /**
      * This method is used to define new fields for adding or editing a task
@@ -27,17 +31,19 @@ class TestTaskAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\Additional
      *
      * @param array $taskInfo Reference to the array containing the info used in the add/edit form
      * @param AbstractTask|null $task When editing, reference to the current task. NULL when adding.
-     * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module)
+     * @param SchedulerModuleController $schedulerModule Reference to the calling object (Scheduler's BE module)
      * @return array Array containing all the information pertaining to the additional fields
      */
-    public function getAdditionalFields(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
+    public function getAdditionalFields(array &$taskInfo, $task, SchedulerModuleController $schedulerModule)
     {
+        $currentSchedulerModuleAction = $schedulerModule->getCurrentAction();
+
         // Initialize extra field value
         if (empty($taskInfo['email'])) {
-            if ($parentObject->CMD === 'add') {
+            if ($currentSchedulerModuleAction->equals(Action::ADD)) {
                 // In case of new task and if field is empty, set default email address
                 $taskInfo['email'] = $GLOBALS['BE_USER']->user['email'];
-            } elseif ($parentObject->CMD === 'edit') {
+            } elseif ($currentSchedulerModuleAction->equals(Action::EDIT)) {
                 // In case of edit, and editing a test task, set to internal value if not data was submitted already
                 $taskInfo['email'] = $task->email;
             } else {
@@ -63,14 +69,17 @@ class TestTaskAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\Additional
      * If the task class is not relevant, the method is expected to return TRUE
      *
      * @param array     $submittedData Reference to the array containing the data submitted by the user
-     * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module)
+     * @param SchedulerModuleController $schedulerModule Reference to the calling object (Scheduler's BE module)
      * @return bool TRUE if validation was ok (or selected class is not relevant), FALSE otherwise
      */
-    public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
+    public function validateAdditionalFields(array &$submittedData, SchedulerModuleController $schedulerModule)
     {
         $submittedData['email'] = trim($submittedData['email']);
         if (empty($submittedData['email'])) {
-            $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.noEmail'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
+            $this->addMessage(
+                $GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.noEmail'),
+                FlashMessage::ERROR
+            );
             $result = false;
         } else {
             $result = true;
@@ -85,7 +94,7 @@ class TestTaskAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\Additional
      * @param array $submittedData Array containing the data submitted by the user
      * @param \TYPO3\CMS\Scheduler\Task\AbstractTask $task Reference to the current task object
      */
-    public function saveAdditionalFields(array $submittedData, \TYPO3\CMS\Scheduler\Task\AbstractTask $task)
+    public function saveAdditionalFields(array $submittedData, AbstractTask $task)
     {
         $task->email = $submittedData['email'];
     }
index 887063c..2261b31 100644 (file)
@@ -14,31 +14,39 @@ namespace TYPO3\CMS\Scheduler\Task;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend;
+use TYPO3\CMS\Core\Messaging\FlashMessage;
+use TYPO3\CMS\Scheduler\AbstractAdditionalFieldProvider;
+use TYPO3\CMS\Scheduler\Controller\SchedulerModuleController;
+use TYPO3\CMS\Scheduler\Task\Enumeration\Action;
+
 /**
  * Additional BE fields for caching framework garbage collection task.
  * Creates a multi selectbox with all available cache backends to select from.
  */
-class CachingFrameworkGarbageCollectionAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface
+class CachingFrameworkGarbageCollectionAdditionalFieldProvider extends AbstractAdditionalFieldProvider
 {
     /**
      * Add a multi select box with all available cache backends.
      *
      * @param array $taskInfo Reference to the array containing the info used in the add/edit form
      * @param AbstractTask|null $task When editing, reference to the current task. NULL when adding.
-     * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module)
+     * @param SchedulerModuleController $schedulerModule Reference to the calling object (Scheduler's BE module)
      * @return array Array containing all the information pertaining to the additional fields
      */
-    public function getAdditionalFields(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
+    public function getAdditionalFields(array &$taskInfo, $task, SchedulerModuleController $schedulerModule)
     {
+        $currentSchedulerModuleAction = $schedulerModule->getCurrentAction();
+
         // Initialize selected fields
         if (empty($taskInfo['scheduler_cachingFrameworkGarbageCollection_selectedBackends'])) {
             $taskInfo['scheduler_cachingFrameworkGarbageCollection_selectedBackends'] = [];
-            if ($parentObject->CMD === 'add') {
+            if ($currentSchedulerModuleAction->equals(Action::ADD)) {
                 // In case of new task, set to dbBackend if it's available
-                if (in_array(\TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class, $this->getRegisteredBackends())) {
-                    $taskInfo['scheduler_cachingFrameworkGarbageCollection_selectedBackends'][] = \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class;
+                if (in_array(Typo3DatabaseBackend::class, $this->getRegisteredBackends())) {
+                    $taskInfo['scheduler_cachingFrameworkGarbageCollection_selectedBackends'][] = Typo3DatabaseBackend::class;
                 }
-            } elseif ($parentObject->CMD === 'edit') {
+            } elseif ($currentSchedulerModuleAction->equals(Action::EDIT)) {
                 // In case of editing the task, set to currently selected value
                 $taskInfo['scheduler_cachingFrameworkGarbageCollection_selectedBackends'] = $task->selectedBackends;
             }
@@ -60,21 +68,21 @@ class CachingFrameworkGarbageCollectionAdditionalFieldProvider implements \TYPO3
      * Checks that all selected backends exist in available backend list
      *
      * @param array $submittedData Reference to the array containing the data submitted by the user
-     * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module)
+     * @param SchedulerModuleController $schedulerModule Reference to the calling object (Scheduler's BE module)
      * @return bool TRUE if validation was ok (or selected class is not relevant), FALSE otherwise
      */
-    public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
+    public function validateAdditionalFields(array &$submittedData, SchedulerModuleController $schedulerModule)
     {
         $validData = true;
         $availableBackends = $this->getRegisteredBackends();
         if (is_array($submittedData['scheduler_cachingFrameworkGarbageCollection_selectedBackends'])) {
             $invalidBackends = array_diff($submittedData['scheduler_cachingFrameworkGarbageCollection_selectedBackends'], $availableBackends);
             if (!empty($invalidBackends)) {
-                $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.selectionOfNonExistingCacheBackends'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
+                $this->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.selectionOfNonExistingCacheBackends'), FlashMessage::ERROR);
                 $validData = false;
             }
         } else {
-            $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.noCacheBackendSelected'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
+            $this->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.noCacheBackendSelected'), FlashMessage::ERROR);
             $validData = false;
         }
         return $validData;
@@ -86,7 +94,7 @@ class CachingFrameworkGarbageCollectionAdditionalFieldProvider implements \TYPO3
      * @param array $submittedData Contains data submitted by the user
      * @param \TYPO3\CMS\Scheduler\Task\AbstractTask $task Reference to the current task object
      */
-    public function saveAdditionalFields(array $submittedData, \TYPO3\CMS\Scheduler\Task\AbstractTask $task)
+    public function saveAdditionalFields(array $submittedData, AbstractTask $task)
     {
         $task->selectedBackends = $submittedData['scheduler_cachingFrameworkGarbageCollection_selectedBackends'];
     }
diff --git a/typo3/sysext/scheduler/Classes/Task/Enumeration/Action.php b/typo3/sysext/scheduler/Classes/Task/Enumeration/Action.php
new file mode 100644 (file)
index 0000000..d2b660e
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+declare(strict_types = 1);
+namespace TYPO3\CMS\Scheduler\Task\Enumeration;
+
+/*
+ * 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 TYPO3\CMS\Core\Type\Enumeration;
+
+/**
+ * List of possible scheduler actions
+ */
+final class Action extends Enumeration
+{
+    const __default = self::LIST;
+    const ADD = 'add';
+    const DELETE = 'delete';
+    const EDIT = 'edit';
+    const LIST = 'list';
+    const SAVE = 'save';
+    const SAVE_CLOSE = 'saveclose';
+    const SAVE_NEW = 'savenew';
+    const SET_NEXT_EXECUTION_TIME = 'setNextExecutionTime';
+    const STOP = 'stop';
+    const TOGGLE_HIDDEN = 'toggleHidden';
+}
index 73dd38a..bb583a8 100644 (file)
@@ -16,27 +16,30 @@ namespace TYPO3\CMS\Scheduler\Task;
  */
 
 use TYPO3\CMS\Core\Localization\LanguageService;
-use TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface;
+use TYPO3\CMS\Core\Messaging\FlashMessage;
+use TYPO3\CMS\Scheduler\AbstractAdditionalFieldProvider;
+use TYPO3\CMS\Scheduler\Controller\SchedulerModuleController;
+use TYPO3\CMS\Scheduler\Task\Enumeration\Action;
 
 /**
  * Additional BE fields for ip address anonymization task.
  */
-class IpAnonymizationAdditionalFieldProvider implements AdditionalFieldProviderInterface
+class IpAnonymizationAdditionalFieldProvider extends AbstractAdditionalFieldProvider
 {
     /**
      * Add additional fields
      *
      * @param array $taskInfo Reference to the array containing the info used in the add/edit form
      * @param AbstractTask|null $task When editing, reference to the current task. NULL when adding.
-     * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module)
+     * @param SchedulerModuleController $schedulerModule Reference to the calling object (Scheduler's BE module)
      * @return array Array containing all the information pertaining to the additional fields
      */
-    public function getAdditionalFields(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
+    public function getAdditionalFields(array &$taskInfo, $task, SchedulerModuleController $schedulerModule)
     {
         $additionalFields = [];
-        $additionalFields['task_ipAnonymization_table'] = $this->getTableAdditionalField($taskInfo, $task, $parentObject);
-        $additionalFields['task_ipAnonymization_numberOfDays'] = $this->getNumberOfDaysAdditionalField($taskInfo, $task, $parentObject);
-        $additionalFields['task_ipAnonymization_mask'] = $this->getMaskAdditionalField($taskInfo, $task, $parentObject);
+        $additionalFields['task_ipAnonymization_table'] = $this->getTableAdditionalField($taskInfo, $task, $schedulerModule);
+        $additionalFields['task_ipAnonymization_numberOfDays'] = $this->getNumberOfDaysAdditionalField($taskInfo, $task, $schedulerModule);
+        $additionalFields['task_ipAnonymization_mask'] = $this->getMaskAdditionalField($taskInfo, $task, $schedulerModule);
         return $additionalFields;
     }
 
@@ -45,20 +48,21 @@ class IpAnonymizationAdditionalFieldProvider implements AdditionalFieldProviderI
      *
      * @param array $taskInfo Reference to the array containing the info used in the add/edit form
      * @param AbstractTask|null $task When editing, reference to the current task. NULL when adding.
-     * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module)
+     * @param SchedulerModuleController $schedulerModule Reference to the calling object (Scheduler's BE module)
      * @return array Array containing all the information pertaining to the additional fields
      */
-    protected function getTableAdditionalField(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
+    protected function getTableAdditionalField(array &$taskInfo, $task, SchedulerModuleController $schedulerModule)
     {
-        $tableConfiguration = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][\TYPO3\CMS\Scheduler\Task\IpAnonymizationTask::class]['options']['tables'];
+        $currentSchedulerModuleAction = $schedulerModule->getCurrentAction();
+        $tableConfiguration = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][IpAnonymizationTask::class]['options']['tables'];
         $options = [];
         // Add an empty option on top if an existing task is configured
         // with a table that can not be found in configuration anymore
-        if ($parentObject->CMD === 'edit' && !array_key_exists($task->table, $tableConfiguration)) {
+        if (!array_key_exists($task->table, $tableConfiguration) && $currentSchedulerModuleAction->equals(Action::EDIT)) {
             $options[] = '<option value="" selected="selected"></option>';
         }
         foreach ($tableConfiguration as $tableName => $configuration) {
-            if ($parentObject->CMD === 'add' && empty($options)) {
+            if ($currentSchedulerModuleAction->equals(Action::ADD) && empty($options)) {
                 // Select first table by default if adding a new task
                 $options[] = '<option value="' . $tableName . '" selected="selected">' . $tableName . '</option>';
             } elseif ($task->table === $tableName) {
@@ -87,10 +91,10 @@ class IpAnonymizationAdditionalFieldProvider implements AdditionalFieldProviderI
      *
      * @param array $taskInfo Reference to the array containing the info used in the add/edit form
      * @param AbstractTask|null $task When editing, reference to the current task. NULL when adding.
-     * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module)
+     * @param SchedulerModuleController $schedulerModule Reference to the calling object (Scheduler's BE module)
      * @return array Array containing all the information pertaining to the additional fields
      */
-    protected function getNumberOfDaysAdditionalField(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
+    protected function getNumberOfDaysAdditionalField(array &$taskInfo, $task, SchedulerModuleController $schedulerModule)
     {
         $fieldId = 'scheduler_ipAnonymization_numberOfDays';
         if (empty($taskInfo[$fieldId])) {
@@ -112,10 +116,10 @@ class IpAnonymizationAdditionalFieldProvider implements AdditionalFieldProviderI
      *
      * @param array $taskInfo Reference to the array containing the info used in the add/edit form
      * @param AbstractTask|null $task When editing, reference to the current task. NULL when adding.
-     * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module)
+     * @param SchedulerModuleController $schedulerModule Reference to the calling object (Scheduler's BE module)
      * @return array Array containing all the information pertaining to the additional fields
      */
-    protected function getMaskAdditionalField(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
+    protected function getMaskAdditionalField(array &$taskInfo, $task, SchedulerModuleController $schedulerModule)
     {
         $fieldId = 'scheduler_ipAnonymization_mask';
         if (empty($taskInfo[$fieldId])) {
@@ -146,13 +150,13 @@ class IpAnonymizationAdditionalFieldProvider implements AdditionalFieldProviderI
      * Validate additional fields
      *
      * @param array $submittedData Reference to the array containing the data submitted by the user
-     * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module)
+     * @param SchedulerModuleController $schedulerModule Reference to the calling object (Scheduler's BE module)
      * @return bool True if validation was ok (or selected class is not relevant), false otherwise
      */
-    public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
+    public function validateAdditionalFields(array &$submittedData, SchedulerModuleController $schedulerModule)
     {
-        $validData = $this->validateTableAdditionalField($submittedData, $parentObject);
-        $validData &= $this->validateNumberOfDaysAdditionalField($submittedData, $parentObject);
+        $validData = $this->validateTableAdditionalField($submittedData, $schedulerModule);
+        $validData &= $this->validateNumberOfDaysAdditionalField($submittedData, $schedulerModule);
         return $validData;
     }
 
@@ -160,13 +164,13 @@ class IpAnonymizationAdditionalFieldProvider implements AdditionalFieldProviderI
      * Checks given table for existence in configuration array
      *
      * @param array $submittedData Reference to the array containing the data submitted by the user
-     * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module)
+     * @param SchedulerModuleController $schedulerModule Reference to the calling object (Scheduler's BE module)
      * @return bool True if table exists in configuration, false otherwise
      */
-    public function validateTableAdditionalField(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
+    public function validateTableAdditionalField(array &$submittedData, SchedulerModuleController $schedulerModule)
     {
         $validData = false;
-        $tableConfiguration = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][\TYPO3\CMS\Scheduler\Task\IpAnonymizationTask::class]['options']['tables'];
+        $tableConfiguration = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][IpAnonymizationTask::class]['options']['tables'];
         if (!isset($submittedData['scheduler_ipAnonymization_table'])) {
             $validData = true;
         } elseif (array_key_exists($submittedData['scheduler_ipAnonymization_table'], $tableConfiguration)) {
@@ -179,10 +183,10 @@ class IpAnonymizationAdditionalFieldProvider implements AdditionalFieldProviderI
      * Checks if given number of days is a positive integer
      *
      * @param array $submittedData Reference to the array containing the data submitted by the user
-     * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module)
+     * @param SchedulerModuleController $schedulerModule Reference to the calling object (Scheduler's BE module)
      * @return bool True if validation was ok (or selected class is not relevant), false otherwise
      */
-    public function validateNumberOfDaysAdditionalField(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
+    public function validateNumberOfDaysAdditionalField(array &$submittedData, SchedulerModuleController $schedulerModule)
     {
         $validData = false;
         if (!isset($submittedData['scheduler_ipAnonymization_numberOfDays'])) {
@@ -191,7 +195,7 @@ class IpAnonymizationAdditionalFieldProvider implements AdditionalFieldProviderI
             $validData = true;
         } else {
             // Issue error message
-            $parentObject->addMessage($this->getLanguageService()->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.invalidNumberOfDays'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
+            $this->addMessage($this->getLanguageService()->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.invalidNumberOfDays'), FlashMessage::ERROR);
         }
         return $validData;
     }
@@ -202,7 +206,7 @@ class IpAnonymizationAdditionalFieldProvider implements AdditionalFieldProviderI
      * @param array $submittedData Contains data submitted by the user
      * @param \TYPO3\CMS\Scheduler\Task\AbstractTask $task Reference to the current task object
      */
-    public function saveAdditionalFields(array $submittedData, \TYPO3\CMS\Scheduler\Task\AbstractTask $task)
+    public function saveAdditionalFields(array $submittedData, AbstractTask $task)
     {
         $task->table = $submittedData['scheduler_ipAnonymization_table'];
         $task->mask = (int)$submittedData['scheduler_ipAnonymization_mask'];
index 4e177c8..528c60a 100644 (file)
@@ -18,13 +18,14 @@ use TYPO3\CMS\Core\Database\Connection;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface;
+use TYPO3\CMS\Scheduler\AbstractAdditionalFieldProvider;
 use TYPO3\CMS\Scheduler\Controller\SchedulerModuleController;
+use TYPO3\CMS\Scheduler\Task\Enumeration\Action;
 
 /**
  * Additional BE fields for optimize database table task.
  */
-class OptimizeDatabaseTableAdditionalFieldProvider implements AdditionalFieldProviderInterface
+class OptimizeDatabaseTableAdditionalFieldProvider extends AbstractAdditionalFieldProvider
 {
     /**
      * @var string
@@ -36,18 +37,20 @@ class OptimizeDatabaseTableAdditionalFieldProvider implements AdditionalFieldPro
      *
      * @param array $taskInfo Reference to the array containing the info used in the add/edit form
      * @param AbstractTask|null $task When editing, reference to the current task. NULL when adding.
-     * @param SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module)
+     * @param SchedulerModuleController $schedulerModule Reference to the calling object (Scheduler's BE module)
      * @return array Array containing all the information pertaining to the additional fields
      */
-    public function getAdditionalFields(array &$taskInfo, $task, SchedulerModuleController $parentObject)
+    public function getAdditionalFields(array &$taskInfo, $task, SchedulerModuleController $schedulerModule)
     {
+        $currentSchedulerModuleAction = $schedulerModule->getCurrentAction();
+
         // Initialize selected fields
         if (empty($taskInfo['scheduler_optimizeDatabaseTables_selectedTables'])) {
             $taskInfo['scheduler_optimizeDatabaseTables_selectedTables'] = [];
-            if ($parentObject->CMD === 'add') {
+            if ($currentSchedulerModuleAction->equals(Action::ADD)) {
                 // In case of new task, select no tables by default
                 $taskInfo['scheduler_optimizeDatabaseTables_selectedTables'] = [];
-            } elseif ($parentObject->CMD === 'edit') {
+            } elseif ($currentSchedulerModuleAction->equals(Action::EDIT)) {
                 // In case of editing the task, set to currently selected value
                 $taskInfo['scheduler_optimizeDatabaseTables_selectedTables'] = $task->selectedTables;
             }
@@ -74,10 +77,10 @@ class OptimizeDatabaseTableAdditionalFieldProvider implements AdditionalFieldPro
      * Checks that all selected backends exist in available backend list
      *
      * @param array $submittedData Reference to the array containing the data submitted by the user
-     * @param SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module)
+     * @param SchedulerModuleController $schedulerModule Reference to the calling object (Scheduler's BE module)
      * @return bool TRUE if validation was ok (or selected class is not relevant), FALSE otherwise
      */
-    public function validateAdditionalFields(array &$submittedData, SchedulerModuleController $parentObject)
+    public function validateAdditionalFields(array &$submittedData, SchedulerModuleController $schedulerModule)
     {
         $validData = true;
         $availableTables = $this->getOptimizableTables();
@@ -87,14 +90,14 @@ class OptimizeDatabaseTableAdditionalFieldProvider implements AdditionalFieldPro
                 $availableTables
             );
             if (!empty($invalidTables)) {
-                $parentObject->addMessage(
+                $this->addMessage(
                     $GLOBALS['LANG']->sL($this->languageFile . ':msg.selectionOfNonExistingDatabaseTables'),
                     FlashMessage::ERROR
                 );
                 $validData = false;
             }
         } else {
-            $parentObject->addMessage(
+            $this->addMessage(
                 $GLOBALS['LANG']->sL($this->languageFile . ':msg.noDatabaseTablesSelected'),
                 FlashMessage::ERROR
             );
@@ -147,7 +150,7 @@ class OptimizeDatabaseTableAdditionalFieldProvider implements AdditionalFieldPro
         $optimizableTables = $this->getOptimizableTablesForConnection($defaultConnection);
 
         // Retrieve additional optimizable tables that have been remapped to a different connection
-        $tableMap = $GLOBALS['TYPO3_CONF_VARS']['DB']['TableMapping'] ?? false;
+        $tableMap = $GLOBALS['TYPO3_CONF_VARS']['DB']['TableMapping'] ?? [];
         if ($tableMap) {
             // Remove all remapped tables from the list of optimizable tables
             // These tables will be rechecked and possibly re-added to the list
@@ -180,7 +183,7 @@ class OptimizeDatabaseTableAdditionalFieldProvider implements AdditionalFieldPro
      * Retrieve all optimizable tables for a connection, optionally restricted to the subset
      * of table names in the $tableNames array.
      *
-     * @param \TYPO3\CMS\Core\Database\Connection $connection
+     * @param Connection $connection
      * @param array $tableNames
      * @return array
      */
index 812b978..7e66da5 100644 (file)
@@ -14,13 +14,18 @@ namespace TYPO3\CMS\Scheduler\Task;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Messaging\FlashMessage;
+use TYPO3\CMS\Scheduler\AbstractAdditionalFieldProvider;
+use TYPO3\CMS\Scheduler\Controller\SchedulerModuleController;
+use TYPO3\CMS\Scheduler\Task\Enumeration\Action;
+
 /**
  * Additional BE fields for recycler garbage collection task.
  *
  * Creates an integer input field for difference between scheduler run time
  * and file modification time in days to select from.
  */
-class RecyclerGarbageCollectionAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface
+class RecyclerGarbageCollectionAdditionalFieldProvider extends AbstractAdditionalFieldProvider
 {
     /**
      * Default period in days to remove a recycled file
@@ -35,15 +40,17 @@ class RecyclerGarbageCollectionAdditionalFieldProvider implements \TYPO3\CMS\Sch
      *
      * @param array $taskInfo Reference to the array containing the info used in the add/edit form
      * @param AbstractTask|null $task When editing, reference to the current task. NULL when adding.
-     * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module)
+     * @param SchedulerModuleController $schedulerModule Reference to the calling object (Scheduler's BE module)
      * @return array Array containing all the information pertaining to the additional fields
      */
-    public function getAdditionalFields(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
+    public function getAdditionalFields(array &$taskInfo, $task, SchedulerModuleController $schedulerModule)
     {
+        $currentSchedulerModuleAction = $schedulerModule->getCurrentAction();
+
         // Initialize selected fields
         if (!isset($taskInfo['scheduler_recyclerGarbageCollection_numberOfDays'])) {
             $taskInfo['scheduler_recyclerGarbageCollection_numberOfDays'] = $this->defaultNumberOfDays;
-            if ($parentObject->CMD === 'edit') {
+            if ($currentSchedulerModuleAction->equals(Action::EDIT)) {
                 $taskInfo['scheduler_recyclerGarbageCollection_numberOfDays'] = $task->numberOfDays;
             }
         }
@@ -64,17 +71,17 @@ class RecyclerGarbageCollectionAdditionalFieldProvider implements \TYPO3\CMS\Sch
      * Checks if the given value is an integer
      *
      * @param array $submittedData Reference to the array containing the data submitted by the user
-     * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module)
+     * @param SchedulerModuleController $schedulerModule Reference to the calling object (Scheduler's BE module)
      * @return bool TRUE if validation was ok (or selected class is not relevant), FALSE otherwise
      */
-    public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
+    public function validateAdditionalFields(array &$submittedData, SchedulerModuleController $schedulerModule)
     {
         $result = true;
         // Check if number of days is indeed a number and greater or equals to 0
         // If not, fail validation and issue error message
         if (!is_numeric($submittedData['scheduler_recyclerGarbageCollection_numberOfDays']) || (int)$submittedData['scheduler_recyclerGarbageCollection_numberOfDays'] < 0) {
             $result = false;
-            $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.invalidNumberOfDays'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
+            $this->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.invalidNumberOfDays'), FlashMessage::ERROR);
         }
         return $result;
     }
@@ -83,9 +90,9 @@ class RecyclerGarbageCollectionAdditionalFieldProvider implements \TYPO3\CMS\Sch
      * Saves given integer value in task object
      *
      * @param array $submittedData Contains data submitted by the user
-     * @param \TYPO3\CMS\Scheduler\Task\AbstractTask $task Reference to the current task object
+     * @param AbstractTask $task Reference to the current task object
      */
-    public function saveAdditionalFields(array $submittedData, \TYPO3\CMS\Scheduler\Task\AbstractTask $task)
+    public function saveAdditionalFields(array $submittedData, AbstractTask $task)
     {
         $task->numberOfDays = (int)$submittedData['scheduler_recyclerGarbageCollection_numberOfDays'];
     }
index 3b9edec..67de8c8 100644 (file)
@@ -14,10 +14,15 @@ namespace TYPO3\CMS\Scheduler\Task;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Messaging\FlashMessage;
+use TYPO3\CMS\Scheduler\AbstractAdditionalFieldProvider;
+use TYPO3\CMS\Scheduler\Controller\SchedulerModuleController;
+use TYPO3\CMS\Scheduler\Task\Enumeration\Action;
+
 /**
  * Additional BE fields for sys log table garbage collection task.
  */
-class TableGarbageCollectionAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface
+class TableGarbageCollectionAdditionalFieldProvider extends AbstractAdditionalFieldProvider
 {
     /**
      * @var array Default number of days by table
@@ -29,16 +34,16 @@ class TableGarbageCollectionAdditionalFieldProvider implements \TYPO3\CMS\Schedu
      *
      * @param array $taskInfo Reference to the array containing the info used in the add/edit form
      * @param AbstractTask|null $task When editing, reference to the current task. NULL when adding.
-     * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module)
+     * @param SchedulerModuleController $schedulerModule Reference to the calling object (Scheduler's BE module)
      * @return array Array containing all the information pertaining to the additional fields
      */
-    public function getAdditionalFields(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
+    public function getAdditionalFields(array &$taskInfo, $task, SchedulerModuleController $schedulerModule)
     {
         $this->initDefaultNumberOfDays();
         $additionalFields = [];
-        $additionalFields['task_tableGarbageCollection_allTables'] = $this->getAllTablesAdditionalField($taskInfo, $task, $parentObject);
-        $additionalFields['task_tableGarbageCollection_table'] = $this->getTableAdditionalField($taskInfo, $task, $parentObject);
-        $additionalFields['task_tableGarbageCollection_numberOfDays'] = $this->getNumberOfDaysAdditionalField($taskInfo, $task, $parentObject);
+        $additionalFields['task_tableGarbageCollection_allTables'] = $this->getAllTablesAdditionalField($taskInfo, $task, $schedulerModule);
+        $additionalFields['task_tableGarbageCollection_table'] = $this->getTableAdditionalField($taskInfo, $task, $schedulerModule);
+        $additionalFields['task_tableGarbageCollection_numberOfDays'] = $this->getNumberOfDaysAdditionalField($taskInfo, $task, $schedulerModule);
         return $additionalFields;
     }
 
@@ -47,7 +52,7 @@ class TableGarbageCollectionAdditionalFieldProvider implements \TYPO3\CMS\Schedu
      */
     protected function initDefaultNumberOfDays()
     {
-        $tableConfiguration = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][\TYPO3\CMS\Scheduler\Task\TableGarbageCollectionTask::class]['options']['tables'];
+        $tableConfiguration = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][TableGarbageCollectionTask::class]['options']['tables'];
         foreach ($tableConfiguration as $tableName => $configuration) {
             if (isset($configuration['expirePeriod'])) {
                 $this->defaultNumberOfDays[$tableName] = $configuration['expirePeriod'];
@@ -60,16 +65,19 @@ class TableGarbageCollectionAdditionalFieldProvider implements \TYPO3\CMS\Schedu
      *
      * @param array $taskInfo Reference to the array containing the info used in the add/edit form
      * @param AbstractTask|null $task When editing, reference to the current task. NULL when adding.
-     * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module)
+     * @param SchedulerModuleController $schedulerModule Reference to the calling object (Scheduler's BE module)
      * @return array Array containing all the information pertaining to the additional fields
      */
-    protected function getAllTablesAdditionalField(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
+    protected function getAllTablesAdditionalField(array &$taskInfo, $task, SchedulerModuleController $schedulerModule)
     {
-        if ($parentObject->CMD === 'edit') {
+        $currentSchedulerModuleAction = $schedulerModule->getCurrentAction();
+
+        if ($currentSchedulerModuleAction->equals(Action::EDIT)) {
             $checked = $task->allTables === true ? 'checked="checked" ' : '';
         } else {
             $checked = '';
         }
+
         $fieldName = 'tx_scheduler[scheduler_tableGarbageCollection_allTables]';
         $fieldId = 'task_tableGarbageCollection_allTables';
         $fieldHtml = '<div class="checkbox"><label><input type="checkbox" ' . $checked . ' name="' . $fieldName . '" ' . 'id="' . $fieldId . '"></label></div>';
@@ -79,6 +87,7 @@ class TableGarbageCollectionAdditionalFieldProvider implements \TYPO3\CMS\Schedu
             'cshKey' => '_MOD_system_txschedulerM1',
             'cshLabel' => $fieldId
         ];
+
         return $fieldConfiguration;
     }
 
@@ -87,20 +96,21 @@ class TableGarbageCollectionAdditionalFieldProvider implements \TYPO3\CMS\Schedu
      *
      * @param array $taskInfo Reference to the array containing the info used in the add/edit form
      * @param AbstractTask|null $task When editing, reference to the current task. NULL when adding.
-     * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module)
+     * @param SchedulerModuleController $schedulerModule Reference to the calling object (Scheduler's BE module)
      * @return array Array containing all the information pertaining to the additional fields
      */
-    protected function getTableAdditionalField(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
+    protected function getTableAdditionalField(array &$taskInfo, $task, SchedulerModuleController $schedulerModule)
     {
-        $tableConfiguration = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][\TYPO3\CMS\Scheduler\Task\TableGarbageCollectionTask::class]['options']['tables'];
+        $currentSchedulerModuleAction = $schedulerModule->getCurrentAction();
+        $tableConfiguration = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][TableGarbageCollectionTask::class]['options']['tables'];
         $options = [];
         // Add an empty option on top if an existing task is configured
         // with a table that can not be found in configuration anymore
-        if ($parentObject->CMD === 'edit' && !array_key_exists($task->table, $tableConfiguration)) {
+        if (!array_key_exists($task->table, $tableConfiguration) && $currentSchedulerModuleAction->equals(Action::EDIT)) {
             $options[] = '<option value="" selected="selected"></option>';
         }
         foreach ($tableConfiguration as $tableName => $configuration) {
-            if ($parentObject->CMD === 'add' && empty($options)) {
+            if ($currentSchedulerModuleAction->equals(Action::ADD) && empty($options)) {
                 // Select first table by default if adding a new task
                 $options[] = '<option value="' . $tableName . '" selected="selected">' . $tableName . '</option>';
             } elseif ($task->table === $tableName) {
@@ -134,18 +144,19 @@ class TableGarbageCollectionAdditionalFieldProvider implements \TYPO3\CMS\Schedu
      *
      * @param array $taskInfo Reference to the array containing the info used in the add/edit form
      * @param AbstractTask|null $task When editing, reference to the current task. NULL when adding.
-     * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module)
+     * @param SchedulerModuleController $schedulerModule Reference to the calling object (Scheduler's BE module)
      * @return array Array containing all the information pertaining to the additional fields
      */
-    protected function getNumberOfDaysAdditionalField(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
+    protected function getNumberOfDaysAdditionalField(array &$taskInfo, $task, SchedulerModuleController $schedulerModule)
     {
+        $currentSchedulerModuleAction = $schedulerModule->getCurrentAction();
         // Initialize selected fields
         $disabled = '';
         if (empty($taskInfo['scheduler_tableGarbageCollection_numberOfDays'])) {
-            if ($parentObject->CMD === 'add') {
+            if ($currentSchedulerModuleAction->equals(Action::ADD)) {
                 // In case of new task, set to 180 days
                 $taskInfo['scheduler_tableGarbageCollection_numberOfDays'] = 180;
-            } elseif ($parentObject->CMD === 'edit') {
+            } elseif ($currentSchedulerModuleAction->equals(Action::EDIT)) {
                 // In case of editing the task, set to currently selected value
                 $taskInfo['scheduler_tableGarbageCollection_numberOfDays'] = $task->numberOfDays;
                 if ($task->numberOfDays === 0 && !isset($this->defaultNumberOfDays[$task->table])) {
@@ -172,14 +183,14 @@ class TableGarbageCollectionAdditionalFieldProvider implements \TYPO3\CMS\Schedu
      * Validate additional fields
      *
      * @param array $submittedData Reference to the array containing the data submitted by the user
-     * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module)
+     * @param SchedulerModuleController $schedulerModule Reference to the calling object (Scheduler's BE module)
      * @return bool True if validation was ok (or selected class is not relevant), false otherwise
      */
-    public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
+    public function validateAdditionalFields(array &$submittedData, SchedulerModuleController $schedulerModule)
     {
-        $validData = $this->validateAllTablesAdditionalField($submittedData, $parentObject);
-        $validData &= $this->validateTableAdditionalField($submittedData, $parentObject);
-        $validData &= $this->validateNumberOfDaysAdditionalField($submittedData, $parentObject);
+        $validData = $this->validateAllTablesAdditionalField($submittedData);
+        $validData &= $this->validateTableAdditionalField($submittedData);
+        $validData &= $this->validateNumberOfDaysAdditionalField($submittedData);
         return $validData;
     }
 
@@ -187,10 +198,9 @@ class TableGarbageCollectionAdditionalFieldProvider implements \TYPO3\CMS\Schedu
      * Checks if all table field is correct
      *
      * @param array $submittedData Reference to the array containing the data submitted by the user
-     * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module)
      * @return bool True if data is valid
      */
-    public function validateAllTablesAdditionalField(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
+    public function validateAllTablesAdditionalField(array &$submittedData)
     {
         $validData = false;
         if (!isset($submittedData['scheduler_tableGarbageCollection_allTables'])) {
@@ -205,13 +215,12 @@ class TableGarbageCollectionAdditionalFieldProvider implements \TYPO3\CMS\Schedu
      * Checks given table for existence in configuration array
      *
      * @param array $submittedData Reference to the array containing the data submitted by the user
-     * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module)
      * @return bool True if table exists in configuration, false otherwise
      */
-    public function validateTableAdditionalField(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
+    public function validateTableAdditionalField(array &$submittedData)
     {
         $validData = false;
-        $tableConfiguration = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][\TYPO3\CMS\Scheduler\Task\TableGarbageCollectionTask::class]['options']['tables'];
+        $tableConfiguration = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][TableGarbageCollectionTask::class]['options']['tables'];
         if (!isset($submittedData['scheduler_tableGarbageCollection_table'])) {
             $validData = true;
         } elseif (array_key_exists($submittedData['scheduler_tableGarbageCollection_table'], $tableConfiguration)) {
@@ -224,10 +233,9 @@ class TableGarbageCollectionAdditionalFieldProvider implements \TYPO3\CMS\Schedu
      * Checks if given number of days is a positive integer
      *
      * @param array $submittedData Reference to the array containing the data submitted by the user
-     * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module)
      * @return bool True if validation was ok (or selected class is not relevant), false otherwise
      */
-    public function validateNumberOfDaysAdditionalField(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
+    public function validateNumberOfDaysAdditionalField(array &$submittedData)
     {
         $validData = false;
         if (!isset($submittedData['scheduler_tableGarbageCollection_numberOfDays'])) {
@@ -236,7 +244,7 @@ class TableGarbageCollectionAdditionalFieldProvider implements \TYPO3\CMS\Schedu
             $validData = true;
         } else {
             // Issue error message
-            $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.invalidNumberOfDays'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
+            $this->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.invalidNumberOfDays'), FlashMessage::ERROR);
         }
         return $validData;
     }
@@ -247,7 +255,7 @@ class TableGarbageCollectionAdditionalFieldProvider implements \TYPO3\CMS\Schedu
      * @param array $submittedData Contains data submitted by the user
      * @param \TYPO3\CMS\Scheduler\Task\AbstractTask $task Reference to the current task object
      */
-    public function saveAdditionalFields(array $submittedData, \TYPO3\CMS\Scheduler\Task\AbstractTask $task)
+    public function saveAdditionalFields(array $submittedData, AbstractTask $task)
     {
         $task->allTables = $submittedData['scheduler_tableGarbageCollection_allTables'] === 'on';
         $task->table = $submittedData['scheduler_tableGarbageCollection_table'];