예제 #1
0
 /**
  * @test
  */
 public function setControllerObjectNameAndSetControllerCommandNameUnsetTheBuiltCommandObject()
 {
     $request = new Request();
     $request->setControllerObjectName('TYPO3\\FLOW3\\Command\\CacheCommandController');
     $request->setControllerCommandName('flush');
     $request->getCommand();
     $request->setControllerObjectName('TYPO3\\FLOW3\\Command\\BeerCommandController');
     $request->setControllerCommandName('drink');
     $command = $request->getCommand();
     $this->assertEquals('typo3.flow3:beer:drink', $command->getCommandIdentifier());
 }
예제 #2
0
 /**
  * Forwards the request to another command and / or CommandController.
  *
  * Request is directly transferred to the other command / controller
  * without the need for a new request.
  *
  * @param string $commandName
  * @param string $controllerObjectName
  * @param array $arguments
  * @return void
  * @throws \TYPO3\FLOW3\Mvc\Exception\StopActionException
  */
 protected function forward($commandName, $controllerObjectName = NULL, array $arguments = array())
 {
     $this->request->setDispatched(FALSE);
     $this->request->setControllerCommandName($commandName);
     if ($controllerObjectName !== NULL) {
         $this->request->setControllerObjectName($controllerObjectName);
     }
     $this->request->setArguments($arguments);
     $this->arguments->removeAll();
     throw new \TYPO3\FLOW3\Mvc\Exception\StopActionException();
 }
예제 #3
0
 /**
  * Builds a CLI request object from a command line.
  *
  * The given command line may be a string (e.g. "mypackage:foo do-that-thing --force") or
  * an array consisting of the individual parts. The array must not include the script
  * name (like in $argv) but start with command right away.
  *
  * @param mixed $commandLine The command line, either as a string or as an array
  * @return \TYPO3\FLOW3\Cli\Request The CLI request as an object
  */
 public function build($commandLine)
 {
     $request = new Request();
     $request->setControllerObjectName('TYPO3\\FLOW3\\Command\\HelpCommandController');
     $rawCommandLineArguments = is_array($commandLine) ? $commandLine : explode(' ', $commandLine);
     if (count($rawCommandLineArguments) === 0) {
         $request->setControllerCommandName('helpStub');
         return $request;
     }
     $commandIdentifier = trim(array_shift($rawCommandLineArguments));
     try {
         $command = $this->commandManager->getCommandByIdentifier($commandIdentifier);
     } catch (\TYPO3\FLOW3\Mvc\Exception\CommandException $exception) {
         $request->setArgument('exception', $exception);
         $request->setControllerCommandName('error');
         return $request;
     }
     $controllerObjectName = $this->objectManager->getObjectNameByClassName($command->getControllerClassName());
     $controllerCommandName = $command->getControllerCommandName();
     $request->setControllerObjectName($controllerObjectName);
     $request->setControllerCommandName($controllerCommandName);
     list($commandLineArguments, $exceedingCommandLineArguments) = $this->parseRawCommandLineArguments($rawCommandLineArguments, $controllerObjectName, $controllerCommandName);
     $request->setArguments($commandLineArguments);
     $request->setExceedingArguments($exceedingCommandLineArguments);
     return $request;
 }