feat: streamlined display of hotel image, name and address
This commit is contained in:
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\BusProNet\DataProvider\CountryDataProvider;
|
||||
use App\BusProNet\Model\Hotel;
|
||||
use App\BusProNet\XmlLoader\HotelLoader;
|
||||
use App\Form\Model\BookingDto;
|
||||
@@ -24,6 +25,7 @@ class BookingSummaryDataService
|
||||
private readonly BookingPriceCalculatorService $priceCalculator,
|
||||
private readonly CmsDataService $cmsDataService,
|
||||
private readonly HotelLoader $hotelLoader,
|
||||
private readonly CountryDataProvider $countryDataProvider,
|
||||
private readonly CacheInterface $cache,
|
||||
private readonly LoggerInterface $logger,
|
||||
) {
|
||||
@@ -182,7 +184,7 @@ class BookingSummaryDataService
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a hotel's address from street and city.
|
||||
* Formats a hotel's address from street, city and country.
|
||||
*/
|
||||
private function formatHotelAddress(?Hotel $hotel): ?string
|
||||
{
|
||||
@@ -190,7 +192,8 @@ class BookingSummaryDataService
|
||||
return null;
|
||||
}
|
||||
|
||||
$parts = array_filter([$hotel->street, $hotel->city]);
|
||||
$countryName = $this->countryDataProvider->get($hotel->country)?->name;
|
||||
$parts = array_filter([$hotel->street, $hotel->city, $countryName]);
|
||||
|
||||
return [] === $parts ? null : implode("\n", $parts);
|
||||
}
|
||||
|
||||
@@ -31,20 +31,22 @@ class CmsDataService
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches only the hotel images from the CMS using normalized codes.
|
||||
* Fetches only the hotel images from the CMS.
|
||||
*
|
||||
* The product code is normalized for CMS lookup while the hotel code
|
||||
* is passed as-is for better matching results.
|
||||
*
|
||||
* @return array<string, mixed>|null The images array or null if unavailable
|
||||
*/
|
||||
public function getProductImages(string $productCode, ?string $hotelCode = null): ?array
|
||||
{
|
||||
$normalizedProduct = $this->normalizeCode($productCode);
|
||||
$normalizedHotel = $this->normalizeCode($hotelCode);
|
||||
|
||||
if (null === $normalizedProduct) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$result = $this->getProductDetails($normalizedProduct, $normalizedHotel);
|
||||
$result = $this->getProductDetails($normalizedProduct, $hotelCode);
|
||||
|
||||
if (true === isset($result['success']) && false === $result['success']) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user