在typo3 V10中如何在extbase控制器中重定向到404页面

问题描述 投票:0回答:1

在TYPO3 v10中,您不能再使用$ TSFE-> pageNotFoundAndExit()。但是,当使用ErrorController PageNotFound方法时,控制器操作中的$this->request会给出异常。

typo3 typo3-10.x
1个回答
0
投票
$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);
© www.soinside.com 2019 - 2024. All rights reserved.