From 306c6b809ffeb865f6435362ce8cac574cc71eff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Thu, 1 Oct 2026 14:16:47 +0200 Subject: [PATCH] feat: show hotel icons on hotel and product detail pages addresses #86965w970 --- .../Classes/Domain/Model/Hotel.php | 17 ++++ .../Classes/Middleware/ApiMiddleware.php | 67 +-------------- .../Classes/Utility/HotelIconUtility.php | 83 +++++++++++++++++++ .../Private/Assets/images/icons_sprite.svg | 24 +++++- .../Private/Partials/Hotel/Details.html | 10 +++ 5 files changed, 132 insertions(+), 69 deletions(-) create mode 100644 public/typo3conf/ext/ep_products/Classes/Utility/HotelIconUtility.php diff --git a/public/typo3conf/ext/ep_products/Classes/Domain/Model/Hotel.php b/public/typo3conf/ext/ep_products/Classes/Domain/Model/Hotel.php index b32d36a1..097fbe8f 100644 --- a/public/typo3conf/ext/ep_products/Classes/Domain/Model/Hotel.php +++ b/public/typo3conf/ext/ep_products/Classes/Domain/Model/Hotel.php @@ -27,6 +27,7 @@ namespace EP\EpProducts\Domain\Model; * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ +use EP\EpProducts\Utility\HotelIconUtility; use TYPO3\CMS\Extbase\Domain\Model\FileReference; use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; use TYPO3\CMS\Extbase\Persistence\ObjectStorage; @@ -1253,4 +1254,20 @@ class Hotel extends AbstractEntity implements TeaserInterface { $this->distanceLift = $distanceLift; } + + public function getIcons(): array + { + return HotelIconUtility::getIcons([ + 'beds_count' => $this->bedsCount, + 'parking_count' => $this->parkingCount, + 'altitude' => $this->altitude, + 'distance_bus' => $this->distanceBus, + 'distance_lift' => $this->distanceLift, + 'shower' => $this->shower, + 'partyroom' => $this->partyroom, + 'gamesroom' => $this->gamesroom, + 'sauna' => $this->sauna, + 'wifi' => $this->wifi, + ]); + } } diff --git a/public/typo3conf/ext/ep_products/Classes/Middleware/ApiMiddleware.php b/public/typo3conf/ext/ep_products/Classes/Middleware/ApiMiddleware.php index 82e55372..aa109a47 100644 --- a/public/typo3conf/ext/ep_products/Classes/Middleware/ApiMiddleware.php +++ b/public/typo3conf/ext/ep_products/Classes/Middleware/ApiMiddleware.php @@ -3,6 +3,7 @@ namespace EP\EpProducts\Middleware; use EP\EpProducts\Service\MyEpImageService; +use EP\EpProducts\Utility\HotelIconUtility; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\MiddlewareInterface; @@ -217,70 +218,6 @@ class ApiMiddleware implements MiddlewareInterface $images = $this->serializeImages($this->hotelImageService->getImages((int) $hotel['uid'])); - // map fields to icon ids and labels - $icons = []; - - if (($hotel['beds_count'] ?? 0) > 0) { - $icons[] = [ - 'icon' => 'bed', - 'label' => sprintf('%d Betten', $hotel['beds_count']), - ]; - } - if (($hotel['parking_count'] ?? 0) > 0) { - $icons[] = [ - 'icon' => 'parking', - 'label' => sprintf('%d Parkplätze', $hotel['parking_count']), - ]; - } - if ($hotel['altitude'] ?? null) { - $icons[] = [ - 'icon' => 'mountain', - 'label' => $hotel['altitude'], - ]; - } - if ($hotel['distance_bus'] ?? null) { - $icons[] = [ - 'icon' => 'bus', - 'label' => $hotel['distance_bus'], - ]; - } - if ($hotel['distance_lift'] ?? null) { - $icons[] = [ - 'icon' => 'lift', - 'label' => $hotel['distance_lift'], - ]; - } - if ($hotel['shower'] ?? null) { - $icons[] = [ - 'icon' => 'shower', - 'label' => $hotel['shower'], - ]; - } - if ($hotel['partyroom'] ?? false) { - $icons[] = [ - 'icon' => 'party', - 'label' => 'Partyzimmer', - ]; - } - if ($hotel['gamesroom'] ?? false) { - $icons[] = [ - 'icon' => 'dice', - 'label' => 'Spielezimmer', - ]; - } - if ($hotel['sauna'] ?? false) { - $icons[] = [ - 'icon' => 'sauna', - 'label' => 'Sauna', - ]; - } - if ($hotel['wifi'] ?? false) { - $icons[] = [ - 'icon' => 'wifi', - 'label' => 'WiFi', - ]; - } - return [ 'name' => $hotel['name'], 'code' => $hotel['code'], @@ -290,7 +227,7 @@ class ApiMiddleware implements MiddlewareInterface 'additional_information' => $hotel['additional_information'], 'address' => $hotel['address'], 'images' => $images, - 'icons' => $icons, + 'icons' => HotelIconUtility::getIcons($hotel), 'region' => $this->fetchRegionData((int) $hotel['region']), ]; } diff --git a/public/typo3conf/ext/ep_products/Classes/Utility/HotelIconUtility.php b/public/typo3conf/ext/ep_products/Classes/Utility/HotelIconUtility.php new file mode 100644 index 00000000..21cb8707 --- /dev/null +++ b/public/typo3conf/ext/ep_products/Classes/Utility/HotelIconUtility.php @@ -0,0 +1,83 @@ + + */ + public static function getIcons(array $hotel): array + { + $icons = []; + + if (($hotel['beds_count'] ?? 0) > 0) { + $icons[] = [ + 'icon' => 'bed', + 'label' => sprintf('%d Betten', $hotel['beds_count']), + ]; + } + if (($hotel['parking_count'] ?? 0) > 0) { + $icons[] = [ + 'icon' => 'parking', + 'label' => sprintf('%d Parkplätze', $hotel['parking_count']), + ]; + } + if ($hotel['altitude'] ?? null) { + $icons[] = [ + 'icon' => 'mountain', + 'label' => $hotel['altitude'], + ]; + } + if ($hotel['distance_bus'] ?? null) { + $icons[] = [ + 'icon' => 'bus', + 'label' => $hotel['distance_bus'], + ]; + } + if ($hotel['distance_lift'] ?? null) { + $icons[] = [ + 'icon' => 'lift', + 'label' => $hotel['distance_lift'], + ]; + } + if ($hotel['shower'] ?? null) { + $icons[] = [ + 'icon' => 'shower', + 'label' => $hotel['shower'], + ]; + } + if ($hotel['partyroom'] ?? false) { + $icons[] = [ + 'icon' => 'party', + 'label' => 'Partyzimmer', + ]; + } + if ($hotel['gamesroom'] ?? false) { + $icons[] = [ + 'icon' => 'dice', + 'label' => 'Spielezimmer', + ]; + } + if ($hotel['sauna'] ?? false) { + $icons[] = [ + 'icon' => 'sauna', + 'label' => 'Sauna', + ]; + } + if ($hotel['wifi'] ?? false) { + $icons[] = [ + 'icon' => 'wifi', + 'label' => 'WiFi', + ]; + } + + return $icons; + } +} diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/images/icons_sprite.svg b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/images/icons_sprite.svg index 3547da80..1e817d61 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/images/icons_sprite.svg +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/images/icons_sprite.svg @@ -26,12 +26,9 @@ - - + - - @@ -66,4 +63,23 @@ + + + + + + + + + + + + + + + + + + + diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Partials/Hotel/Details.html b/public/typo3conf/ext/ep_theme/Resources/Private/Partials/Hotel/Details.html index 1a2c5888..45cba2f2 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Partials/Hotel/Details.html +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Partials/Hotel/Details.html @@ -14,6 +14,16 @@ + + + {hotel.description -> f:format.html()}