2 namespace TYPO3\CMS\Extbase\Scheduler;
51 $this->objectManager =
$objectManager !== null ?
$objectManager : \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
65 public function getAdditionalFields(array &$taskInfo,
$task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule)
68 if ($this->task !== null) {
69 $this->task->setScheduler();
73 if ($this->task !== null && $this->task->getCommandIdentifier()) {
74 $command = $this->commandManager->getCommandByIdentifier($this->task->getCommandIdentifier());
77 $fields = array_merge($fields, $argumentFields);
90 public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule)
104 $task->setCommandIdentifier($submittedData[
'task_extbase'][
'action']);
105 $task->setArguments((array)$submittedData[
'task_extbase'][
'arguments']);
116 $command = $this->commandManager->getCommandByIdentifier($this->task->getCommandIdentifier());
119 'label' =>
'<strong>' . $command->getDescription() .
'</strong>'
130 $commands = $this->commandManager->getAvailableCommands();
132 foreach ($commands as $command) {
133 if ($command->isInternal() ===
true || $command->isCliOnly() ===
true) {
136 $className = $command->getControllerClassName();
137 if (strpos($className,
'\\')) {
138 $classNameParts = explode(
'\\', $className);
140 if (strpos($className,
'TYPO3\\CMS\\') === 0) {
141 $classPartsToSkip = 2;
143 $classPartsToSkip = 1;
145 $classNameParts = array_slice($classNameParts, $classPartsToSkip);
146 $extensionName = $classNameParts[0];
147 $controllerName = $classNameParts[2];
149 $classNameParts = explode(
'_', $className);
150 $extensionName = $classNameParts[1];
151 $controllerName = $classNameParts[3];
153 $identifier = $command->getCommandIdentifier();
154 $options[$identifier] = $extensionName .
' ' . str_replace(
'CommandController',
'', $controllerName) .
': ' . $command->getControllerCommandName();
157 $currentlySelectedCommand = $this->task !== null ? $this->task->getCommandIdentifier() : null;
175 $argumentValues = $this->task->getArguments();
176 foreach ($argumentDefinitions as $argument) {
177 $name = $argument->getName();
179 $this->task->addDefaultValue($name, $defaultValue);
180 $value = isset($argumentValues[$name]) ? $argumentValues[$name] : $defaultValue;
181 $fields[$name] = array(
199 if (!$extensionName) {
200 list($extensionName, $commandControllerName, $commandName) = explode(
':', $this->task->getCommandIdentifier());
202 $label = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($localLanguageKey, $extensionName);
212 protected function getArgumentType(\TYPO3\CMS\Extbase\Mvc\Cli\CommandArgumentDefinition $argument)
214 $command = $this->commandManager->getCommandByIdentifier($this->task->getCommandIdentifier());
215 $controllerClassName = $command->getControllerClassName();
216 $methodName = $command->getControllerCommandName() .
'Command';
217 $tags = $this->reflectionService->getMethodTagsValues($controllerClassName, $methodName);
218 foreach ($tags[
'param'] as $tag) {
219 list($argumentType, $argumentVariableName) = explode(
' ', $tag);
220 if (substr($argumentVariableName, 1) === $argument->getName()) {
221 return $argumentType;
233 protected function getArgumentLabel(\TYPO3\CMS\Extbase\Mvc\Cli\CommandArgumentDefinition $argument)
235 $argumentName = $argument->getName();
236 list($extensionName, $commandControllerName, $commandName) = explode(
':', $this->task->getCommandIdentifier());
237 $path = array(
'command', $commandControllerName, $commandName,
'arguments', $argumentName);
238 $labelNameIndex = implode(
'.', $path);
241 $label =
'Argument: ' . $argumentName;
243 $descriptionIndex = $labelNameIndex .
'.description';
245 if ((
string)$description ===
'') {
246 $description = $argument->getDescription();
248 if ((
string)$description !==
'') {
249 $label .=
'. <em>' . htmlspecialchars($description) .
'</em>';
263 $argumentName = $argument->getName();
264 $command = $this->commandManager->getCommandByIdentifier($this->task->getCommandIdentifier());
265 $argumentReflection = $this->reflectionService->getMethodParameters($command->getControllerClassName(), $command->getControllerCommandName() .
'Command');
266 $defaultValue = $argumentReflection[$argumentName][
'defaultValue'];
267 if ($type ===
'boolean') {
268 $defaultValue = (bool)$defaultValue ? 1 : 0;
270 return $defaultValue;
280 $index =
'task.action';
283 $label =
'CommandController Command. <em>Save and reopen to define command arguments</em>';
299 '<select class="form-control" name="tx_scheduler[task_extbase][' . htmlspecialchars($name) .
']">'
301 foreach ($options as $optionValue => $optionLabel) {
302 $selected = $optionValue === $selectedOptionValue ?
' selected="selected"' :
'';
303 array_push($html,
'<option title="test" value="' . htmlspecialchars($optionValue) .
'"' . $selected .
'>' . htmlspecialchars($optionLabel) .
'</option>');
305 array_push($html,
'</select>');
306 return implode(LF, $html);
316 protected function renderField(\TYPO3\CMS\Extbase\Mvc\Cli\CommandArgumentDefinition $argument, $currentValue)
319 $name = $argument->getName();
320 $fieldName =
'tx_scheduler[task_extbase][arguments][' . htmlspecialchars($name) .
']';
321 if ($type ===
'boolean') {
323 $html =
'<input type="hidden" name="' . $fieldName .
'" value="0">';
324 $html .=
'<div class="checkbox"><label><input type="checkbox" name="' . $fieldName .
'" value="1" ' . ((bool)$currentValue ?
' checked="checked"' :
'') .
'></label></div>';
327 $html =
'<input class="form-control" type="text" name="' . $fieldName .
'" value="' . htmlspecialchars($currentValue) .
'"> ';