feat: travel info shows the hotel address maintained in TYPO3

The address MyEP returns for a travel is meant for the bus driver (e.g.
a parking spot near the hotel), so guests were shown a technical
location instead of the hotel's postal address.

The hotel from MyEP is now matched to its TYPO3 record by code or
additional code, and the editorial "Anschrift" is shown with its line
breaks. If no hotel matches, it is hidden or its address is empty, the
MyEP address is still shown as before, so no travel info loses its
address block.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
frommeandClaude Opus 5.5 committed 2026-11-05 18:16:07 +01:00
1 parent e6d1009b52
commit 54567d7d79
3 files changed
+37 -5

No files matched your search

@@ -3,7 +3,9 @@
namespace EP\EpProducts\Controller; namespace EP\EpProducts\Controller;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
use EP\EpProducts\Domain\Model\Hotel;
use EP\EpProducts\Domain\Model\Travelinfo; use EP\EpProducts\Domain\Model\Travelinfo;
use EP\EpProducts\Domain\Repository\HotelRepository;
use EP\EpProducts\Domain\Repository\TravelinfoRepository; use EP\EpProducts\Domain\Repository\TravelinfoRepository;
use EP\EpProducts\MyEP\ApiClient; use EP\EpProducts\MyEP\ApiClient;
use EP\EpProducts\MyEP\ApiException; use EP\EpProducts\MyEP\ApiException;
@@ -19,6 +21,7 @@ class TravelinfoController extends ActionController
public function __construct( public function __construct(
private readonly ApiClient $apiClient, private readonly ApiClient $apiClient,
private readonly TravelinfoRepository $travelinfoRepository, private readonly TravelinfoRepository $travelinfoRepository,
private readonly HotelRepository $hotelRepository,
) { ) {
} }
@@ -94,11 +97,20 @@ class TravelinfoController extends ActionController
$departureDayTime = $serviceDetail['dayTime']; $departureDayTime = $serviceDetail['dayTime'];
} }
// MyEP's hotel address is meant for the bus driver, so the editorial one is preferred
$hotel = null;
$hotelCode = $travelData['hotel']['code'] ?? null;
if (null !== $hotelCode && '' !== $hotelCode) {
$hotel = $this->hotelRepository->findOneByCodeOrAdditionalCode($hotelCode);
}
$hotelAddress = $hotel instanceof Hotel ? trim((string)$hotel->getAddress()) : '';
$this->view->assign('travelInfo', $travelInfo); $this->view->assign('travelInfo', $travelInfo);
$this->view->assign('travelData', $travelData); $this->view->assign('travelData', $travelData);
$this->view->assign('pickupsPlanning', $pickupsPlanning); $this->view->assign('pickupsPlanning', $pickupsPlanning);
$this->view->assign('courses', $courses); $this->view->assign('courses', $courses);
$this->view->assign('board', $board); $this->view->assign('board', $board);
$this->view->assign('departureDayTime', $departureDayTime); $this->view->assign('departureDayTime', $departureDayTime);
$this->view->assign('hotelAddress', $hotelAddress);
} }
} }
@@ -243,4 +243,17 @@ class HotelRepository extends AbstractRepository
return $query->execute(); return $query->execute();
} }
public function findOneByCodeOrAdditionalCode(string $code): ?Hotel
{
$query = $this->createQuery();
$query->matching(
$query->logicalOr(
$query->equals('code', $code),
$query->equals('additionalCodes.code', $code)
)
);
return $query->execute()->getFirst();
}
} }
@@ -69,11 +69,18 @@
Adresse Adresse
</h3> </h3>
<p> <p>
{travelData.hotel.name} <f:if condition="{hotelAddress}">
<br> <f:then>
{travelData.hotel.street} <f:format.nl2br>{hotelAddress}</f:format.nl2br>
<br> </f:then>
{travelData.hotel.country} {travelData.hotel.city} <f:else>
{travelData.hotel.name}
<br>
{travelData.hotel.street}
<br>
{travelData.hotel.country} {travelData.hotel.city}
</f:else>
</f:if>
</p> </p>
</f:else> </f:else>
</f:if> </f:if>