From 6da01ca9b7181cd8a21fdd8391c68796b0143ea1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Mon, 6 Jan 2025 15:34:54 +0100 Subject: [PATCH] feat: link travelinfo from MyE&P by travel code --- config/sites/ep-reisen/config.yaml | 7 + .../Controller/TravelinfoController.php | 68 ++- .../ext/ep_products/ext_localconf.php | 2 +- .../Private/Partials/TravelInfo.html | 406 ++++++++++++++++++ .../Private/Templates/Travelinfo/Index.html | 399 +---------------- .../Private/Templates/Travelinfo/MyEp.html | 11 + .../Templates/Travelinfo/TravelCode.html | 11 + 7 files changed, 492 insertions(+), 412 deletions(-) create mode 100644 public/typo3conf/ext/ep_theme/Resources/Private/Partials/TravelInfo.html create mode 100644 public/typo3conf/ext/ep_theme/Resources/Private/Templates/Travelinfo/MyEp.html create mode 100644 public/typo3conf/ext/ep_theme/Resources/Private/Templates/Travelinfo/TravelCode.html diff --git a/config/sites/ep-reisen/config.yaml b/config/sites/ep-reisen/config.yaml index e14f6d68..20cd46ae 100644 --- a/config/sites/ep-reisen/config.yaml +++ b/config/sites/ep-reisen/config.yaml @@ -265,6 +265,11 @@ routeEnhancers: _controller: 'Travelinfo::myep' _arguments: buspro_id: busProId + - + routePath: '/{travel_code}' + _controller: 'Travelinfo::travelCode' + _arguments: + travel_code: travelCode defaultController: 'Travelinfo::index' aspects: travel_info: @@ -275,6 +280,8 @@ routeEnhancers: type: PassthroughMapper buspro_id: type: PassthroughMapper + travel_code: + type: PassthroughMapper requirements: travel_date: '\d{4}\-\d{2}\-\d{2}|\d{2}\d{2}\d{4}' buspro_id: '\d+' diff --git a/public/typo3conf/ext/ep_products/Classes/Controller/TravelinfoController.php b/public/typo3conf/ext/ep_products/Classes/Controller/TravelinfoController.php index 638a536a..a161caf6 100644 --- a/public/typo3conf/ext/ep_products/Classes/Controller/TravelinfoController.php +++ b/public/typo3conf/ext/ep_products/Classes/Controller/TravelinfoController.php @@ -5,6 +5,7 @@ namespace EP\EpProducts\Controller; use EP\EpProducts\Domain\Model\Date; use EP\EpProducts\Domain\Model\Travelinfo; use EP\EpProducts\Domain\Repository\DateRepository; +use EP\EpProducts\Domain\Repository\ProductRepository; use EP\EpProducts\Domain\Repository\TravelInfoRepository; use TYPO3\CMS\Core\Http\ImmediateResponseException; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -23,10 +24,52 @@ class TravelinfoController extends ActionController */ private $travelInfoRepository; - public function __construct(DateRepository $dateRepository, TravelInfoRepository $travelInfoRepository) - { + /** + * @var ProductRepository + */ + private $productRepository; + + public function __construct( + DateRepository $dateRepository, + TravelInfoRepository $travelInfoRepository, + ProductRepository $productRepository + ) { $this->dateRepository = $dateRepository; $this->travelInfoRepository = $travelInfoRepository; + $this->productRepository = $productRepository; + } + + public function travelCodeAction(string $travelCode) + { + $travelCode = strtoupper($travelCode); + + /** @var Date $date */ + $date = $this->dateRepository->findOneByCode($travelCode); + + [$code, ] = explode('/', $travelCode); + + $product = $this->productRepository->findOneByCode($code); + + if (null === $product) { + $response = GeneralUtility::makeInstance(ErrorController::class)->pageNotFoundAction( + $GLOBALS['TYPO3_REQUEST'], + 'Produkt nicht gefunden' + ); + throw new ImmediateResponseException($response, 1731071856); + } + + $travelinfo = $this->travelInfoRepository->findOneByProduct($product); + + if (null === $travelinfo) { + $response = GeneralUtility::makeInstance(ErrorController::class)->pageNotFoundAction( + $GLOBALS['TYPO3_REQUEST'], + 'Reiseinformationen nicht gefunden' + ); + throw new ImmediateResponseException($response, 1731071856); + } + + $this->view->assign('travelinfo', $travelinfo); + $this->view->assign('date', $date); } public function myepAction(int $busProId) @@ -52,18 +95,11 @@ class TravelinfoController extends ActionController throw new ImmediateResponseException($response, 1731071856); } - $this->redirect( - 'index', - null, - null, - [ - 'travelinfo' => $travelinfo, - 'travelDate' => $date->getDateStart()->format('Y-m-d'), - ] - ); + $this->view->assign('travelinfo', $travelinfo); + $this->view->assign('date', $date); } - public function indexAction(Travelinfo $travelinfo, string $travelDate) + public function indexAction(Travelinfo $travelinfo, string $travelDate = null) { $product = $travelinfo->getProduct(); @@ -71,8 +107,12 @@ class TravelinfoController extends ActionController $travelDate = (\DateTimeImmutable::createFromFormat('dmY', $travelDate))->format('Y-m-d'); } - /** @var Date $date */ - $date = $this->dateRepository->findForProductAndDate($product, $travelDate)->getFirst(); + if (null === $travelDate) { + $date = null; + } else { + /** @var Date $date */ + $date = $this->dateRepository->findForProductAndDate($product, $travelDate)->getFirst(); + } $this->view->assign('travelinfo', $travelinfo); $this->view->assign('date', $date); diff --git a/public/typo3conf/ext/ep_products/ext_localconf.php b/public/typo3conf/ext/ep_products/ext_localconf.php index 46982863..5eafb957 100644 --- a/public/typo3conf/ext/ep_products/ext_localconf.php +++ b/public/typo3conf/ext/ep_products/ext_localconf.php @@ -252,7 +252,7 @@ $boot = function () { 'EP.ep_products', 'travelinfo', [ - 'Travelinfo' => 'index,myep', + 'Travelinfo' => 'index,myep,travelCode', ] ); diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Partials/TravelInfo.html b/public/typo3conf/ext/ep_theme/Resources/Private/Partials/TravelInfo.html new file mode 100644 index 00000000..a56c7214 --- /dev/null +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Partials/TravelInfo.html @@ -0,0 +1,406 @@ + + + +
+
+ +
+
+
+ Reiseinformation +
+ +
+
+
+
+

+ {travelinfo.subline} + {travelinfo.headline} +

+ {travelinfo.introText -> f:format.html()} + +

+ {date.product.name} {date.dateStart -> f:format.date(format: 'd.m.Y')} - {date.dateEnd -> f:format.date(format: 'd.m.Y')} +

+
+
+
+
+
+
+
+ +
+
+ Anreise +
+
+
+ + + +

+ Adresse +

+

+ {date.hotel.name} +
+ {date.hotel.address -> f:format.nl2br()} +

+
+
+ + + + + + +
+
+ +
+ +
+
+
+
+
+
+
+ +

+ Eigenanreise +

+ {travelinfo.selfArrangedText -> f:format.html()} +
+
+
+
+
+

+ Sei vorbereitet! + Organisatorisches +

+
+
+ + + +
+
+
+ +
+
+
+ +
+
+ Weitere Infos +
+
+
+ {travelinfo.additionalInfo -> f:format.html()} +
+
+
+ +
+
+
+ Wichtige Telefon­nummern +
+
+
+ +

+ Busbegleitung / Reiseleitung +
+ {date.guide.name} {date.guide.phone} +

+
+ {travelinfo.importantPhoneNumbers -> f:format.html()} +
+
+
+ +
+
+
+ Wichtige Links vor Ort +
+
+
+ {travelinfo.importantLinks -> f:format.html()} +
+
+
+
+
+
+ {travelinfo.footerText -> f:format.html()} + +
+
+ +
+
+ + +
+
+ +
+
+ +
+
+
+
+
+

+ {teaser.title} +

+ + +

+ {date.board} +

+
+ + + +

+ Folgende Kurse finden statt +

+
    + +
  • + {course.label} +
  • +
    +
+
+ +

+ Bei Eurer Reise finden keine Kurse statt. +

+
+
+
+
+ {teaser.bodytext -> f:format.html()} +
+
+ +
+
+
+
+
+ + + +
+ +
+
+ {item.title -> f:format.raw()} +
+
+
+ + +

+ Bus-Zustiege +

+

+ Bitte findet euch mindestens 20 Minuten vor Abfahrt an der gebuchten Haltestelle ein. +

+ {travelinfo.busInfoText -> f:format.html()} + + + + + + + + + + + +
+ Zustieg + + Datum/Uhrzeit +
+ {pickup.city}
{pickup.street} +
+ {pickup.date}
{f:if(condition: pickup.time, then: '{pickup.time} Uhr', else: '???')} +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Travelinfo/Index.html b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Travelinfo/Index.html index de49fead..9015bcde 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Travelinfo/Index.html +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Travelinfo/Index.html @@ -5,402 +5,7 @@ -
-
- -
-
-
- Reiseinformation -
- -
-
-
-
-

- {travelinfo.subline} - {travelinfo.headline} -

- {travelinfo.introText -> f:format.html()} - -

- {date.product.name} {date.dateStart -> f:format.date(format: 'd.m.Y')} - {date.dateEnd -> f:format.date(format: 'd.m.Y')} -

-
-
-
-
-
-
-
- -
-
- Anreise -
-
-
- - - -

- Adresse -

-

- {date.hotel.name} -
- {date.hotel.address -> f:format.nl2br()} -

-
-
- - - - - - -
-
- -
- -
-
-
-
-
-
-
- -

- Eigenanreise -

- {travelinfo.selfArrangedText -> f:format.html()} -
-
-
-
-
-

- Sei vorbereitet! - Organisatorisches -

-
-
- - - -
-
-
- -
-
-
- -
-
- Weitere Infos -
-
-
- {travelinfo.additionalInfo -> f:format.html()} -
-
-
- -
-
-
- Wichtige Telefon­nummern -
-
-
- -

- Busbegleitung / Reiseleitung -
- {date.guide.name} {date.guide.phone} -

-
- {travelinfo.importantPhoneNumbers -> f:format.html()} -
-
-
- -
-
-
- Wichtige Links vor Ort -
-
-
- {travelinfo.importantLinks -> f:format.html()} -
-
-
-
-
-
- {travelinfo.footerText -> f:format.html()} - -
-
- -
-
- - -
-
- -
-
- -
-
-
-
-
-

- {teaser.title} -

- - -

- {date.board} -

-
- - - -

- Folgende Kurse finden statt -

-
    - -
  • - {course.label} -
  • -
    -
-
- -

- Bei Eurer Reise finden keine Kurse statt. -

-
-
-
-
- {teaser.bodytext -> f:format.html()} -
-
- -
-
-
-
-
- - - -
- -
-
- {item.title -> f:format.raw()} -
-
-
- - -

- Bus-Zustiege -

-

- Bitte findet euch mindestens 20 Minuten vor Abfahrt an der gebuchten Haltestelle ein. -

- {travelinfo.busInfoText -> f:format.html()} - - - - - - - - - - - -
- Zustieg - - Datum/Uhrzeit -
- {pickup.city}
{pickup.street} -
- {pickup.date}
{f:if(condition: pickup.time, then: '{pickup.time} Uhr', else: '???')} -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Travelinfo/MyEp.html b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Travelinfo/MyEp.html new file mode 100644 index 00000000..816f3889 --- /dev/null +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Travelinfo/MyEp.html @@ -0,0 +1,11 @@ + + + + + + + + + diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Travelinfo/TravelCode.html b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Travelinfo/TravelCode.html new file mode 100644 index 00000000..816f3889 --- /dev/null +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Travelinfo/TravelCode.html @@ -0,0 +1,11 @@ + + + + + + + + +