$GLOBALS['TSFE']->pageNotFoundAndExit('');
is currently used, but instead I would like to redirect to a page ID.
With the command redirectToUri
, I could find no solution, or didn't work.
Code:
/**
* initialize action show
* @return void
*/
public function initializeShowAction() {
if ($this->request->hasArgument('xxx')) {
if ( $xxx=$this->xxxRepository->findByUid(
intval($this->request->getArgument('xxx'))
) ) {
$this->request->setArgument('xxx',$xxx);
return;
}
}
$GLOBALS['TSFE']->pageNotFoundAndExit('');
}
You can build an uri with the following code in your controller:
$uriBuilder = $this->uriBuilder;
$uri = $uriBuilder
->setTargetPageUid($pageUid)
->build();
$this->redirectToUri($uri, 0, 404);
In your controller you can use one of the following:
# Internal redirect of request to another controller
$this->forward($actionName, $controllerName, $extensionName, array $arguments);
# External HTTP redirect to another controller
$this->redirect($actionName, $controllerName, $extensionName, array $arguments, $pageUid, $delay = 0, $statusCode = 303);
# Redirect to URI
$this->redirectToURI($uri, $delay=0, $statusCode=303);
# Send HTTP status code
$this->throwStatus($statusCode, $statusMessage, $content);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With