Created
September 17, 2024 08:31
-
-
Save BlackhawkG7/082cf2e756a3893c54b94c22513808bd to your computer and use it in GitHub Desktop.
Extbase Error 404
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use TYPO3\CMS\Frontend\Controller\ErrorController; | |
use TYPO3\CMS\Core\Http\ImmediateResponseException; | |
use TYPO3\CMS\Frontend\Page\PageAccessFailureReasons; | |
use TYPO3\CMS\Extbase\Mvc\RequestInterface; | |
/** | |
* processRequest | |
* | |
* @param \TYPO3\CMS\Extbase\Mvc\RequestInterface $request | |
* @throws \Exception|\TYPO3\CMS\Extbase\Property\Exception | |
*/ | |
public function processRequest(RequestInterface $request): ResponseInterface | |
{ | |
try { | |
return parent::processRequest($request, $response); | |
} | |
catch(\TYPO3\CMS\Extbase\Property\Exception\TargetNotFoundException $e) { | |
if ($e instanceof \TYPO3\CMS\Extbase\Property\Exception\TargetNotFoundException) { | |
$response = GeneralUtility::makeInstance(ErrorController::class)->pageNotFoundAction( | |
$GLOBALS['TYPO3_REQUEST'], | |
'404 - Not Found', | |
['code' => PageAccessFailureReasons::PAGE_NOT_FOUND] | |
); | |
throw new ImmediateResponseException($response); | |
} else { | |
throw $e; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment