/** * Gets a set of fields covering arguments which must be sent to $currentControllerAction. * Also registers the default values of those fields with the Task, allowing * them to be read upon execution. * * @param array $argumentDefinitions * @return array */ protected function getCommandControllerActionArgumentFields(array $argumentDefinitions) { $fields = array(); $argumentValues = $this->task->getArguments(); foreach ($argumentDefinitions as $argument) { $name = $argument->getName(); $defaultValue = $this->getDefaultArgumentValue($argument); $this->task->addDefaultValue($name, $defaultValue); $value = isset($argumentValues[$name]) ? $argumentValues[$name] : $defaultValue; $fields[$name] = array('code' => $this->renderField($argument, $value), 'label' => $this->getArgumentLabel($argument)); } return $fields; }
/** * @test */ public function getArgumentsReturnsCorrectArguments() { $this->task->_set('arguments', array('Foo')); $this->assertSame(array('Foo'), $this->task->getArguments()); }
/** * Execute Task * * If errors occur during Task execution they are thrown as Exceptions which * must be caught manually if you manually execute Tasks through your code. * * @param \TYPO3\CMS\Extbase\Scheduler\Task $task the task to execute * @return void */ public function execute(\TYPO3\CMS\Extbase\Scheduler\Task $task) { $commandIdentifier = $task->getCommandIdentifier(); list($extensionKey, $controllerName, $commandName) = explode(':', $commandIdentifier); $extensionName = \TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($extensionKey); $this->initialize(array('extensionName' => $extensionName)); // execute command $command = $this->commandManager->getCommandByIdentifier($commandIdentifier); $this->request->setControllerObjectName($command->getControllerClassName()); $this->request->setControllerCommandName($command->getControllerCommandName()); $this->request->setArguments($task->getArguments()); $this->dispatcher->dispatch($this->request, $this->response); $this->shutdown(); }