‪TYPO3CMS  10.4
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'] === $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-control" name="' . $fieldName . '" id="' . $fieldId . '">' . implode("\n", $options) . '</select>';
75 
76  $fieldConfiguration = [
77  'code' => $fieldHtml,
78  'label' => 'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.fileStorageIndexing.storage',
79  'cshKey' => '_MOD_system_txschedulerM1',
80  'cshLabel' => $fieldId
81  ];
82  return $fieldConfiguration;
83  }
84 
92  public function ‪validateAdditionalFields(array &$submittedData, ‪SchedulerModuleController $parentObject)
93  {
94  $value = $submittedData['scheduler_fileStorageIndexing_storage'];
96  return false;
97  }
98  if (GeneralUtility::makeInstance(ResourceFactory::class)->getStorageObject($submittedData['scheduler_fileStorageIndexing_storage']) !== null) {
99  return true;
100  }
101  return false;
102  }
103 
111  public function ‪saveAdditionalFields(array $submittedData, ‪AbstractTask $task)
112  {
113  if (!$task instanceof ‪FileStorageIndexingTask) {
114  throw new \InvalidArgumentException('Task not of type FileStorageExtractionTask', 1384275697);
115  }
116  $task->storageUid = (int)$submittedData['scheduler_fileStorageIndexing_storage'];
117  }
118 }
‪TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger
‪static bool canBeInterpretedAsInteger($var)
Definition: MathUtility.php:74
‪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\Scheduler\Task\AbstractTask
Definition: AbstractTask.php:35
‪TYPO3\CMS\Scheduler\Controller\SchedulerModuleController
Definition: SchedulerModuleController.php:56
‪TYPO3\CMS\Core\Resource\ResourceFactory
Definition: ResourceFactory.php:41
‪TYPO3\CMS\Scheduler\Task\FileStorageIndexingTask
Definition: FileStorageIndexingTask.php:28
‪TYPO3\CMS\Core\Resource\StorageRepository
Definition: StorageRepository.php:31
‪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:92
‪TYPO3\CMS\Scheduler\Task\FileStorageIndexingAdditionalFieldProvider\saveAdditionalFields
‪saveAdditionalFields(array $submittedData, AbstractTask $task)
Definition: FileStorageIndexingAdditionalFieldProvider.php:111
‪TYPO3\CMS\Core\Utility\MathUtility
Definition: MathUtility.php:22
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface
Definition: AdditionalFieldProviderInterface.php:25