/** * Gets the default value of argument * * @param \TYPO3\CMS\Extbase\Mvc\Cli\CommandArgumentDefinition $argument * @return mixed */ protected function getDefaultArgumentValue(\TYPO3\CMS\Extbase\Mvc\Cli\CommandArgumentDefinition $argument) { $type = $this->getArgumentType($argument); $argumentName = $argument->getName(); $command = $this->commandManager->getCommandByIdentifier($this->task->getCommandIdentifier()); $argumentReflection = $this->reflectionService->getMethodParameters($command->getControllerClassName(), $command->getControllerCommandName() . 'Command'); $defaultValue = $argumentReflection[$argumentName]['defaultValue']; if ($type === 'boolean') { $defaultValue = (bool) $defaultValue ? 1 : 0; } return $defaultValue; }
/** * @test */ public function getCommandIdentifierReturnsCorrectCommandIdentifier() { $this->task->_set('commandIdentifier', 'Foo'); $this->assertSame('Foo', $this->task->getCommandIdentifier()); }
/** * 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(); }