【问题标题】:How to redirect to 404 page in a extbase controller in typo3 V10如何在typo3 V10的extbase控制器中重定向到404页面
【发布时间】:2020-09-25 10:43:40
【问题描述】:

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

【问题讨论】:

    标签: typo3 typo3-10.x


    【解决方案1】:
    $TSFE->pageNotFoundAndExit() will be removed in TYPO3 v10.0. Use TYPO3's ErrorController with Request/Response objects instead.
    

    (https://docs.typo3.org/c/typo3/cms-core/master/en-us/Changelog/9.2/Deprecation-83883-PageNotFoundAndErrorHandlingInFrontend.html)

    在您的控制器中,您必须使用$GLOBALS['TYPO3_REQUEST'] 而不是$this->request

    提示:使用ImmediateResponseException 不会调用进一步的操作。

    示例方法:

       $response = GeneralUtility::makeInstance(ErrorController::class)->pageNotFoundAction(
                $GLOBALS['TYPO3_REQUEST'],
                'your 404 message'
            );
            throw new ImmediateResponseException($response, 1591428020);
    

    【讨论】:

      猜你喜欢
      • 2017-03-25
      • 1970-01-01
      • 2020-07-31
      • 1970-01-01
      • 1970-01-01
      • 2012-10-10
      • 1970-01-01
      • 2023-03-18
      • 2019-10-28
      相关资源
      最近更新 更多