TYPO3 CMS  TYPO3_6-2
FileStorageIndexingAdditionalFieldProvider.php
Go to the documentation of this file.
1 <?php
3 
22 
32  public function getAdditionalFields(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject) {
33  if ($task !== NULL && !$task instanceof FileStorageIndexingTask) {
34  throw new \InvalidArgumentException('Task not of type FileStorageExtractionTask', 1384275696);
35  }
36  $additionalFields['scheduler_fileStorageIndexing_storage'] = $this->getAllStoragesField($task);
37  return $additionalFields;
38  }
39 
46  protected function getAllStoragesField(FileStorageIndexingTask $task = NULL) {
48  $storages = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Core\Resource\StorageRepository')->findAll();
49  $options = array();
50  foreach ($storages as $storage) {
51  if ($task != NULL && $task->storageUid === $storage->getUid()) {
52  $options[] = '<option value="' . $storage->getUid() . '" selected="selected">' . $storage->getName() . '</option>';
53  } else {
54  $options[] = '<option value="' . $storage->getUid() . '">' . $storage->getName() . '</option>';
55  }
56  }
57 
58  $fieldName = 'tx_scheduler[scheduler_fileStorageIndexing_storage]';
59  $fieldId = 'scheduler_fileStorageIndexing_storage';
60  $fieldHtml = '<select name="' . $fieldName . '" id="' . $fieldId . '">' . implode("\n", $options) . '</select>';
61 
62  $fieldConfiguration = array(
63  'code' => $fieldHtml,
64  'label' => 'LLL:EXT:scheduler/mod1/locallang.xlf:label.fileStorageIndexing.storage',
65  'cshKey' => '_MOD_system_txschedulerM1',
66  'cshLabel' => $fieldId
67  );
68  return $fieldConfiguration;
69  }
70 
78  public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject) {
79  $value = $submittedData['scheduler_fileStorageIndexing_storage'];
80  if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($value)) {
81  return FALSE;
82  } elseif(\TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getStorageObject($submittedData['scheduler_fileStorageIndexing_storage']) !== NULL) {
83  return TRUE;
84  }
85  return FALSE;
86  }
87 
96  public function saveAdditionalFields(array $submittedData, \TYPO3\CMS\Scheduler\Task\AbstractTask $task) {
97  if (!$task instanceof FileStorageIndexingTask) {
98  throw new \InvalidArgumentException('Task not of type FileStorageExtractionTask', 1384275697);
99  }
100  $task->storageUid = (int)$submittedData['scheduler_fileStorageIndexing_storage'];
101  }
102 
103 }
validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
getAdditionalFields(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
saveAdditionalFields(array $submittedData, \TYPO3\CMS\Scheduler\Task\AbstractTask $task)