‪TYPO3CMS  9.5
FileStorageIndexingAdditionalFieldProvider.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
22 {
32  public function ‪getAdditionalFields(array &$taskInfo, $task, \‪TYPO3\CMS\‪Scheduler\Controller\‪SchedulerModuleController $parentObject)
33  {
34  if ($task !== null && !$task instanceof ‪FileStorageIndexingTask) {
35  throw new \InvalidArgumentException('Task not of type FileStorageExtractionTask', 1384275696);
36  }
37  $additionalFields['scheduler_fileStorageIndexing_storage'] = $this->‪getAllStoragesField($task, $taskInfo);
38  return $additionalFields;
39  }
40 
48  protected function ‪getAllStoragesField(‪FileStorageIndexingTask $task = null, $taskInfo)
49  {
51  $storages = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\‪TYPO3\CMS\Core\Resource\StorageRepository::class)->findAll();
52  $options = [];
53  foreach ($storages as $storage) {
54  $selected = '';
55  if ($task !== null && $task->storageUid === $storage->getUid()) {
56  $selected = ' selected="selected"';
57  } elseif ((int)$taskInfo['scheduler_fileStorageIndexing_storage'] === $storage->getUid()) {
58  $selected = ' selected="selected"';
59  }
60  $options[] = '<option value="' . $storage->getUid() . '" ' . $selected . ' >' . $storage->getName() . '</option>';
61  }
62 
63  $fieldName = 'tx_scheduler[scheduler_fileStorageIndexing_storage]';
64  $fieldId = 'scheduler_fileStorageIndexing_storage';
65  $fieldHtml = '<select class="form-control" name="' . $fieldName . '" id="' . $fieldId . '">' . implode("\n", $options) . '</select>';
66 
67  $fieldConfiguration = [
68  'code' => $fieldHtml,
69  'label' => 'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.fileStorageIndexing.storage',
70  'cshKey' => '_MOD_system_txschedulerM1',
71  'cshLabel' => $fieldId
72  ];
73  return $fieldConfiguration;
74  }
75 
83  public function ‪validateAdditionalFields(array &$submittedData, \‪TYPO3\CMS\‪Scheduler\Controller\‪SchedulerModuleController $parentObject)
84  {
85  $value = $submittedData['scheduler_fileStorageIndexing_storage'];
86  if (!\‪TYPO3\CMS\Core\Utility\‪MathUtility::canBeInterpretedAsInteger($value)) {
87  return false;
88  }
89  if (\‪TYPO3\CMS\Core\Resource\‪ResourceFactory::getInstance()->getStorageObject($submittedData['scheduler_fileStorageIndexing_storage']) !== null) {
90  return true;
91  }
92  return false;
93  }
94 
102  public function ‪saveAdditionalFields(array $submittedData, \‪TYPO3\CMS\‪Scheduler\Task\‪AbstractTask $task)
103  {
104  if (!$task instanceof ‪FileStorageIndexingTask) {
105  throw new \InvalidArgumentException('Task not of type FileStorageExtractionTask', 1384275697);
106  }
107  $task->storageUid = (int)$submittedData['scheduler_fileStorageIndexing_storage'];
108  }
109 }
‪TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger
‪static bool canBeInterpretedAsInteger($var)
Definition: MathUtility.php:73
‪TYPO3\CMS\Scheduler\Task\FileStorageIndexingAdditionalFieldProvider\getAllStoragesField
‪array getAllStoragesField(FileStorageIndexingTask $task=null, $taskInfo)
Definition: FileStorageIndexingAdditionalFieldProvider.php:48
‪TYPO3
‪TYPO3\CMS\Scheduler\Task
Definition: AbstractTask.php:2
‪TYPO3\CMS\Core\Resource\ResourceFactory\getInstance
‪static ResourceFactory getInstance()
Definition: ResourceFactory.php:39
‪TYPO3\CMS\Scheduler\Task\FileStorageIndexingAdditionalFieldProvider\getAdditionalFields
‪array getAdditionalFields(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
Definition: FileStorageIndexingAdditionalFieldProvider.php:32
‪TYPO3\CMS\Scheduler\Task\AbstractTask
Definition: AbstractTask.php:32
‪TYPO3\CMS\Scheduler\Controller\SchedulerModuleController
Definition: SchedulerModuleController.php:53
‪TYPO3\CMS\Scheduler\Task\FileStorageIndexingTask
Definition: FileStorageIndexingTask.php:22
‪TYPO3\CMS\Scheduler\Scheduler
Definition: Scheduler.php:33
‪TYPO3\CMS\Scheduler\Task\FileStorageIndexingAdditionalFieldProvider
Definition: FileStorageIndexingAdditionalFieldProvider.php:22
‪TYPO3\CMS\Scheduler\Task\FileStorageIndexingAdditionalFieldProvider\saveAdditionalFields
‪saveAdditionalFields(array $submittedData, \TYPO3\CMS\Scheduler\Task\AbstractTask $task)
Definition: FileStorageIndexingAdditionalFieldProvider.php:102
‪TYPO3\CMS\Scheduler\Task\FileStorageIndexingAdditionalFieldProvider\validateAdditionalFields
‪bool validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
Definition: FileStorageIndexingAdditionalFieldProvider.php:83
‪TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface
Definition: AdditionalFieldProviderInterface.php:21