[CLEANUP] Code cleanup in ext:reports
[Packages/TYPO3.CMS.git] / typo3 / sysext / reports / Classes / Task / SystemStatusUpdateTaskNotificationEmailField.php
index ea42763..7d9c2f9 100644 (file)
@@ -13,12 +13,18 @@ namespace TYPO3\CMS\Reports\Task;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Core\Messaging\FlashMessage;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Lang\LanguageService;
+use TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface;
+use TYPO3\CMS\Scheduler\Controller\SchedulerModuleController;
+use TYPO3\CMS\Scheduler\Task\AbstractTask;
 
 /**
  * Additional field to set the notification email address(es) for system health
  * issue notifications.
  */
-class SystemStatusUpdateTaskNotificationEmailField implements \TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface
+class SystemStatusUpdateTaskNotificationEmailField implements AdditionalFieldProviderInterface
 {
     /**
      * Additional fields
@@ -42,9 +48,8 @@ class SystemStatusUpdateTaskNotificationEmailField implements \TYPO3\CMS\Schedul
      * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule Reference to the scheduler backend module
      * @return array A two dimensional array, array('Identifier' => array('fieldId' => array('code' => '', 'label' => '', 'cshKey' => '', 'cshLabel' => ''))
      */
-    public function getAdditionalFields(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule)
+    public function getAdditionalFields(array &$taskInfo, $task, SchedulerModuleController $schedulerModule)
     {
-        $fields = array('notificationEmail' => 'textarea');
         if ($schedulerModule->CMD == 'edit') {
             $taskInfo[$this->fieldPrefix . 'NotificationEmail'] = $task->getNotificationEmail();
         }
@@ -71,18 +76,18 @@ class SystemStatusUpdateTaskNotificationEmailField implements \TYPO3\CMS\Schedul
      * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule Reference to the scheduler backend 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 $schedulerModule)
+    public function validateAdditionalFields(array &$submittedData, SchedulerModuleController $schedulerModule)
     {
         $validInput = true;
-        $notificationEmails = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(LF, $submittedData[$this->fieldPrefix . 'NotificationEmail'], true);
+        $notificationEmails = GeneralUtility::trimExplode(LF, $submittedData[$this->fieldPrefix . 'NotificationEmail'], true);
         foreach ($notificationEmails as $notificationEmail) {
-            if (!\TYPO3\CMS\Core\Utility\GeneralUtility::validEmail($notificationEmail)) {
+            if (!GeneralUtility::validEmail($notificationEmail)) {
                 $validInput = false;
                 break;
             }
         }
         if (empty($submittedData[$this->fieldPrefix . 'NotificationEmail']) || !$validInput) {
-            $schedulerModule->addMessage($GLOBALS['LANG']->sL('LLL:EXT:reports/Resources/Private/Language/locallang_reports.xlf:status_updateTaskField_notificationEmails_invalid'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
+            $schedulerModule->addMessage($this->getLanguageService()->sL('LLL:EXT:reports/Resources/Private/Language/locallang_reports.xlf:status_updateTaskField_notificationEmails_invalid'), FlashMessage::ERROR);
             $validInput = false;
         }
         return $validInput;
@@ -95,10 +100,10 @@ class SystemStatusUpdateTaskNotificationEmailField implements \TYPO3\CMS\Schedul
      * @param \TYPO3\CMS\Scheduler\Task\AbstractTask $task Reference to the scheduler backend module
      * @return void
      */
-    public function saveAdditionalFields(array $submittedData, \TYPO3\CMS\Scheduler\Task\AbstractTask $task)
+    public function saveAdditionalFields(array $submittedData, AbstractTask $task)
     {
-        if (!$task instanceof \TYPO3\CMS\Reports\Task\SystemStatusUpdateTask) {
-            throw new \InvalidArgumentException('Expected a task of type ' . \TYPO3\CMS\Reports\Task\SystemStatusUpdateTask::class . ', but got ' . get_class($task), 1295012802);
+        if (!$task instanceof SystemStatusUpdateTask) {
+            throw new \InvalidArgumentException('Expected a task of type ' . SystemStatusUpdateTask::class . ', but got ' . get_class($task), 1295012802);
         }
         $task->setNotificationEmail($submittedData[$this->fieldPrefix . 'NotificationEmail']);
     }
@@ -113,4 +118,12 @@ class SystemStatusUpdateTaskNotificationEmailField implements \TYPO3\CMS\Schedul
     {
         return $this->fieldPrefix . ucfirst($fieldName);
     }
+
+    /**
+     * @return LanguageService
+     */
+    protected function getLanguageService()
+    {
+        return $GLOBALS['LANG'];
+    }
 }