Actions
Feature #64566
closedAbstractController::redirect should have a noCacheHash parameter
Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2015-01-28
Due date:
% Done:
90%
Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:
Description
Hello there,
I recently experienced the need to deactivate all cHash parameters and was lastly stuck at my redirect that would not redirect without a cHash.
I figured out, that there is no way to deactivate it, opposed to the f:link.action or f:link.page from fluid.
So I built this (basically added the functionality to the method):
/** * Redirects the request to another action and / or controller. * * Redirect will be sent to the client which then performs another request to the new URI. * * 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 array $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 * @param boolean $noCacheHash (optional) Choose to not append a cHash to the generated url. * @return void * @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException If the request is not a web request * @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException * @see forward() * @api */ protected function redirect($actionName, $controllerName = NULL, $extensionName = NULL, array $arguments = NULL, $pageUid = NULL, $delay = 0, $statusCode = 303, $noCacheHash = false) { if (!$this->request instanceof \TYPO3\CMS\Extbase\Mvc\Web\Request) { throw new \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException('redirect() only supports web requests.', 1220539734); } if ($controllerName === NULL) { $controllerName = $this->request->getControllerName(); } $this->uriBuilder->reset()->setTargetPageUid($pageUid)->setCreateAbsoluteUri(TRUE)->setUseCacheHash(!$noCacheHash); if (\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SSL')) { $this->uriBuilder->setAbsoluteUriScheme('https'); } $uri = $this->uriBuilder->uriFor($actionName, $arguments, $controllerName, $extensionName); $this->redirectToUri($uri, $delay, $statusCode); }
Best regards
Tizian
Actions