Skip to content

Instantly share code, notes, and snippets.

@BlackhawkG7
Created September 17, 2024 08:31
Show Gist options
  • Save BlackhawkG7/082cf2e756a3893c54b94c22513808bd to your computer and use it in GitHub Desktop.
Save BlackhawkG7/082cf2e756a3893c54b94c22513808bd to your computer and use it in GitHub Desktop.
Extbase Error 404
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