‪TYPO3CMS  ‪main
FileStorageIndexingAdditionalFieldProvider.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
24 
30 {
40  public function ‪getAdditionalFields(array &$taskInfo, $task, ‪SchedulerModuleController $parentObject)
41  {
42  if ($task !== null && !$task instanceof ‪FileStorageIndexingTask) {
43  throw new \InvalidArgumentException('Task not of type FileStorageExtractionTask', 1384275696);
44  }
45  $additionalFields = [];
46  $additionalFields['scheduler_fileStorageIndexing_storage'] = $this->‪getAllStoragesField($task, $taskInfo);
47  return $additionalFields;
48  }
49 
57  protected function ‪getAllStoragesField(‪FileStorageIndexingTask $task = null, $taskInfo)
58  {
60  $storages = GeneralUtility::makeInstance(StorageRepository::class)->findAll();
61  $options = [];
62  foreach ($storages as $storage) {
63  $selected = '';
64  if ($task !== null && $task->storageUid === $storage->getUid()) {
65  $selected = ' selected="selected"';
66  } elseif ((int)($taskInfo['scheduler_fileStorageIndexing_storage'] ?? 0) === $storage->getUid()) {
67  $selected = ' selected="selected"';
68  }
69  $options[] = '<option value="' . $storage->getUid() . '" ' . $selected . ' >' . $storage->getName() . '</option>';
70  }
71 
72  $fieldName = 'tx_scheduler[scheduler_fileStorageIndexing_storage]';
73  $fieldId = 'scheduler_fileStorageIndexing_storage';
74  $fieldHtml = '<select class="form-select" name="' . $fieldName . '" id="' . $fieldId . '">'
75  . implode("\n", $options) . '</select>';
76 
77  $fieldConfiguration = [
78  'code' => $fieldHtml,
79  'label' => 'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.fileStorageIndexing.storage',
80  'cshKey' => '_MOD_system_txschedulerM1',
81  'cshLabel' => $fieldId,
82  'type' => 'select',
83  ];
84  return $fieldConfiguration;
85  }
86 
94  public function ‪validateAdditionalFields(array &$submittedData, ‪SchedulerModuleController $parentObject)
95  {
96  $value = $submittedData['scheduler_fileStorageIndexing_storage'];
98  return false;
99  }
100  if (GeneralUtility::makeInstance(StorageRepository::class)->findByUid($submittedData['scheduler_fileStorageIndexing_storage']) !== null) {
101  return true;
102  }
103  return false;
104  }
105 
113  public function ‪saveAdditionalFields(array $submittedData, ‪AbstractTask $task)
114  {
115  if (!$task instanceof ‪FileStorageIndexingTask) {
116  throw new \InvalidArgumentException('Task not of type FileStorageExtractionTask', 1384275697);
117  }
118  $task->storageUid = (int)$submittedData['scheduler_fileStorageIndexing_storage'];
119  }
120 }
‪TYPO3\CMS\Scheduler\Task\FileStorageIndexingAdditionalFieldProvider\getAllStoragesField
‪array getAllStoragesField(FileStorageIndexingTask $task=null, $taskInfo)
Definition: FileStorageIndexingAdditionalFieldProvider.php:57
‪TYPO3\CMS\Scheduler\Task
Definition: AbstractTask.php:16
‪TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger
‪static bool canBeInterpretedAsInteger(mixed $var)
Definition: MathUtility.php:69
‪TYPO3\CMS\Scheduler\Task\AbstractTask
Definition: AbstractTask.php:33
‪TYPO3\CMS\Scheduler\Controller\SchedulerModuleController
Definition: SchedulerModuleController.php:61
‪TYPO3\CMS\Scheduler\Task\FileStorageIndexingTask
Definition: FileStorageIndexingTask.php:28
‪TYPO3\CMS\Core\Resource\StorageRepository
Definition: StorageRepository.php:38
‪TYPO3\CMS\Scheduler\Task\FileStorageIndexingAdditionalFieldProvider
Definition: FileStorageIndexingAdditionalFieldProvider.php:30
‪TYPO3\CMS\Scheduler\Task\FileStorageIndexingAdditionalFieldProvider\getAdditionalFields
‪array getAdditionalFields(array &$taskInfo, $task, SchedulerModuleController $parentObject)
Definition: FileStorageIndexingAdditionalFieldProvider.php:40
‪TYPO3\CMS\Scheduler\Task\FileStorageIndexingAdditionalFieldProvider\validateAdditionalFields
‪bool validateAdditionalFields(array &$submittedData, SchedulerModuleController $parentObject)
Definition: FileStorageIndexingAdditionalFieldProvider.php:94
‪TYPO3\CMS\Scheduler\Task\FileStorageIndexingAdditionalFieldProvider\saveAdditionalFields
‪saveAdditionalFields(array $submittedData, AbstractTask $task)
Definition: FileStorageIndexingAdditionalFieldProvider.php:113
‪TYPO3\CMS\Core\Resource\ResourceStorage
Definition: ResourceStorage.php:129
‪TYPO3\CMS\Core\Utility\MathUtility
Definition: MathUtility.php:24
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface
Definition: AdditionalFieldProviderInterface.php:25