/** * Maps arguments delivered by the request object to the local controller arguments. * * @return void */ protected function mapRequestArgumentsToControllerArguments() { /** @var Argument $argument */ foreach ($this->arguments as $argument) { $argumentName = $argument->getName(); if ($this->request->hasArgument($argumentName)) { $argument->setValue($this->request->getArgument($argumentName)); continue; } if (!$argument->isRequired()) { continue; } $argumentValue = NULL; $commandArgumentDefinition = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Mvc\\Cli\\CommandArgumentDefinition', $argumentName, TRUE, NULL); while ($argumentValue === NULL) { $argumentValue = $this->output->ask(sprintf('<comment>Please specify the required argument "%s":</comment> ', $commandArgumentDefinition->getDashedName())); } $argument->setValue($argumentValue); } }
/** * @param string $actionName * @throws \TYPO3\CMS\Extbase\Mvc\Exception\AmbiguousCommandIdentifierException * @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentTypeException * @throws \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException * @throws \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchCommandException * @throws \RuntimeException */ protected function dispatchAction($actionName) { $this->executeSilentConfigurationUpgradesIfNeeded(); $arguments = $this->getCommandMethodArguments($actionName . 'Command'); $command = $this->commandManager->getCommandByIdentifier('install:' . strtolower($actionName)); $loopCounter = 0; do { $loopCounter++; $this->output->outputLine(); $this->output->outputLine(sprintf('%s:', $command->getShortDescription())); $actionArguments = array(); foreach ($command->getArgumentDefinitions() as $argumentDefinition) { $argument = $arguments->getArgument($argumentDefinition->getName()); if (isset($this->givenRequestArguments[$argumentDefinition->getName()])) { $actionArguments[$argumentDefinition->getName()] = $this->givenRequestArguments[$argumentDefinition->getName()]; } else { if (!$this->interactiveSetup) { if ($argument->isRequired()) { throw new \RuntimeException(sprintf('Argument "%s" is not set, but is required and user interaction has been disabled!', $argument->getName()), 1405273316); } else { continue; } } $argumentValue = NULL; do { $argumentValue = $this->output->ask(sprintf('<comment>%s (%s):</comment> ', $argumentDefinition->getDescription(), $argument->isRequired() ? 'required' : sprintf('default: "%s"', $argument->getDefaultValue()))); } while ($argumentDefinition->isRequired() && $argumentValue === NULL); $actionArguments[$argumentDefinition->getName()] = $argumentValue !== NULL ? $argumentValue : $argument->getDefaultValue(); } } do { $messages = @unserialize($this->dispatcher->executeCommand('install:' . strtolower($actionName), $actionArguments)); } while ($messages === 'REDIRECT'); $messages = $messages ?: array(); $this->outputMessages($messages); if ($loopCounter > 10) { throw new \RuntimeException('Tried to dispatch "' . $actionName . '" ' . $loopCounter . ' times.', 1405269518); } } while (!empty($messages)); }