/** * Forwards the request to another action and / or controller. * * NOTE: This method only supports web requests and will thrown an exception * if used with other request types. * * @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 $extensionName Name of the extension containing the controller to forward to. If not specified, the current extension is assumed. * @param Tx_Extbase_MVC_Controller_Arguments $arguments Arguments to pass to the target action * @param integer $pageUid Target page uid. If NULL, the current page uid is used * @param integer $delay (optional) The delay in seconds. Default is no delay. * @param integer $statusCode (optional) The HTTP status code for the redirect. Default is "303 See Other" * @return void * @throws Tx_Extbase_MVC_Exception_UnsupportedRequestType If the request is not a web request * @throws Tx_Extbase_MVC_Exception_StopAction * @api */ protected function redirect($actionName, $controllerName = NULL, $extensionName = NULL, array $arguments = NULL, $pageUid = NULL, $delay = 0, $statusCode = 303) { if (!$this->request instanceof Tx_Extbase_MVC_Web_Request) { throw new Tx_Extbase_MVC_Exception_UnsupportedRequestType('redirect() only supports web requests.', 1220539734); } if ($controllerName === NULL) { $controllerName = $this->request->getControllerName(); } $uri = $this->uriBuilder->reset()->setTargetPageUid($pageUid)->uriFor($actionName, $arguments, $controllerName, $extensionName); $this->redirectToURI($uri, $delay, $statusCode); }
/** * Returns a frontend URI independently of current context, with or without extbase, and with or without TSFE * @param string $actionName * @param array $controllerArguments * @param string $controllerName * @param string $extensionName * @param string $pluginName * @return string absolute URI */ public static function buildFrontendUri($actionName, array $controllerArguments, $controllerName, $extensionName = 'newsletter', $pluginName = 'p') { if (!self::$uriBuilder) { self::$uriBuilder = self::buildUriBuilder($extensionName, $pluginName); } $controllerArguments['action'] = $actionName; $controllerArguments['controller'] = $controllerName; $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Extbase_Object_ObjectManager'); $extensionService = $objectManager->get('Tx_Extbase_Service_ExtensionService'); $pluginNamespace = $extensionService->getPluginNamespace($extensionName, $pluginName); $arguments = array($pluginNamespace => $controllerArguments); self::$uriBuilder->reset()->setUseCacheHash(FALSE)->setCreateAbsoluteUri(TRUE)->setArguments($arguments); return self::$uriBuilder->buildFrontendUri() . '&type=1342671779'; }
/** * @test */ public function resetSetsAllOptionsToTheirDefaultValue() { $this->uriBuilder->setArguments(array('test' => 'arguments'))->setSection('testSection')->setFormat('someFormat')->setCreateAbsoluteUri(TRUE)->setAddQueryString(TRUE)->setArgumentsToBeExcludedFromQueryString(array('test' => 'addQueryStringExcludeArguments'))->setLinkAccessRestrictedPages(TRUE)->setTargetPageUid(123)->setTargetPageType(321)->setNoCache(TRUE)->setUseCacheHash(FALSE); $this->uriBuilder->reset(); $this->assertEquals(array(), $this->uriBuilder->getArguments()); $this->assertEquals('', $this->uriBuilder->getSection()); $this->assertEquals('', $this->uriBuilder->getFormat()); $this->assertEquals(FALSE, $this->uriBuilder->getCreateAbsoluteUri()); $this->assertEquals(FALSE, $this->uriBuilder->getAddQueryString()); $this->assertEquals(array(), $this->uriBuilder->getArgumentsToBeExcludedFromQueryString()); $this->assertEquals(FALSE, $this->uriBuilder->getLinkAccessRestrictedPages()); $this->assertEquals(NULL, $this->uriBuilder->getTargetPageUid()); $this->assertEquals(0, $this->uriBuilder->getTargetPageType()); $this->assertEquals(FALSE, $this->uriBuilder->getNoCache()); $this->assertEquals(TRUE, $this->uriBuilder->getUseCacheHash()); }