在TYPO3 v10中,您不能再使用$ TSFE-> pageNotFoundAndExit()。但是,当使用ErrorController PageNotFound方法时,控制器操作中的$this->request
会给出异常。
$TSFE->pageNotFoundAndExit() will be removed in TYPO3 v10.0. Use TYPO3's ErrorController with Request/Response objects instead.
在控制器中,您必须使用$GLOBALS['TYPO3_REQUEST']
而不是$this->request
。
提示:通过使用ImmediateResponseException
,将不会调用其他操作。
示例方法:
$response = GeneralUtility::makeInstance(ErrorController::class)->pageNotFoundAction(
$GLOBALS['TYPO3_REQUEST'],
'your 404 message'
);
throw new ImmediateResponseException($response, 1591428020);