TYPO3 v10: Extbase: Send 404 page not found response

revision 556d905a918e0eb030822084de66276433dbb87b

raw

code.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
use TYPO3\CMS\Core\Http\ImmediateResponseException;   
use TYPO3\CMS\Core\Utility\GeneralUtility;            
use TYPO3\CMS\Frontend\Controller\ErrorController;    
 
class SomeController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
{
    public function someAction($id)
    {
        if (!SomeModel::find($id)) {
            $response = GeneralUtility::makeInstance(ErrorController::class)
                ->pageNotFoundAction($GLOBALS['TYPO3_REQUEST'], 'Record not found.');
            throw new ImmediateResponseException($response, 1617116194);    
        }
    }
}

History