fix: return 404 page for invalid travelinfo urls

This commit is contained in:
Björn Fromme
2024-11-26 15:11:11 +01:00
parent ae7e8b2d45
commit d06f1814e6
@@ -33,6 +33,7 @@ class TravelinfoController extends ActionController
{
/** @var Date $date */
$date = $this->dateRepository->findOneByBusProId($busProId);
$travelinfo = $this->travelInfoRepository->findOneByProduct($date->getProduct());
if (null === $travelinfo) {
@@ -60,6 +61,15 @@ class TravelinfoController extends ActionController
/** @var Date $date */
$date = $this->dateRepository->findForProductAndDate($product, $travelDate)->getFirst();
if (null === $date) {
$response = GeneralUtility::makeInstance(ErrorController::class)->pageNotFoundAction(
$GLOBALS['TYPO3_REQUEST'],
'Reiseinformationen nicht gefunden'
);
throw new ImmediateResponseException($response, 1731071856);
}
$hasCourses = 0 < count($date->getServicesGeneral('KUR'));
$this->view->assign('travelinfo', $travelinfo);