/** * Forwards the request to another action and / or controller. * * Request is directly transfered to the other action / controller * * @param string $actionName Name of the action to forward to * @param string $controllerName Unqualified object name of the controller to forward to. If not specified, the current controller is used. * @param string $packageKey Key of the package containing the controller to forward to. May also contain the sub package, concatenated with backslash (Vendor.Foo\Bar\Baz). If not specified, the current package is assumed. * @param array $arguments Arguments to pass to the target action * @return void * @throws \TYPO3\FLOW3\Mvc\Exception\ForwardException * @see redirect() * @api */ protected function forward($actionName, $controllerName = NULL, $packageKey = NULL, array $arguments = array()) { $nextRequest = clone $this->request; $nextRequest->setControllerActionName($actionName); if ($controllerName !== NULL) { $nextRequest->setControllerName($controllerName); } if ($packageKey !== NULL && strpos($packageKey, '\\') !== FALSE) { list($packageKey, $subpackageKey) = explode('\\', $packageKey, 2); } else { $subpackageKey = NULL; } if ($packageKey !== NULL) { $nextRequest->setControllerPackageKey($packageKey); } if ($subpackageKey !== NULL) { $nextRequest->setControllerSubpackageKey($subpackageKey); } $regularArguments = array(); foreach ($arguments as $argumentName => $argumentValue) { if (substr($argumentName, 0, 2) === '__') { $nextRequest->setArgument($argumentName, $argumentValue); } else { $regularArguments[$argumentName] = $argumentValue; } } $nextRequest->setArguments($this->persistenceManager->convertObjectsToIdentityArrays($regularArguments)); $this->arguments->removeAll(); $forwardException = new \TYPO3\FLOW3\Mvc\Exception\ForwardException(); $forwardException->setNextRequest($nextRequest); throw $forwardException; }
/** * 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(); }
/** * @test */ public function removeAllClearsAllArguments() { $arguments = new Arguments(); $arguments->addArgument(new Argument('foo', 'Text')); $arguments->removeAll(); $this->assertFalse($arguments->hasArgument('foo')); }