fix: revoke caching of bpn product data
This commit is contained in:
@@ -32,30 +32,20 @@ use EP\EpProducts\Domain\Model\Product;
|
||||
use EP\EpProducts\Domain\Repository\ContingentRepository;
|
||||
use EP\EpProducts\Utility\BookingUrlUtility;
|
||||
use League\Period\Period;
|
||||
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
|
||||
|
||||
class ContingentDataService
|
||||
{
|
||||
public const CACHE_TTL = 60 * 60;
|
||||
|
||||
/**
|
||||
* @var ContingentRepository
|
||||
*/
|
||||
protected $contingentRepository;
|
||||
|
||||
/**
|
||||
* @var FrontendInterface
|
||||
*/
|
||||
private $cache;
|
||||
|
||||
/**
|
||||
* @param ContingentRepository $contingentRepository
|
||||
* @param FrontendInterface $cache
|
||||
*/
|
||||
public function __construct(ContingentRepository $contingentRepository, FrontendInterface $cache)
|
||||
public function __construct(ContingentRepository $contingentRepository)
|
||||
{
|
||||
$this->contingentRepository = $contingentRepository;
|
||||
$this->cache = $cache;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,9 +56,6 @@ class ContingentDataService
|
||||
*/
|
||||
public function getAvailableContingents(Hotel $hotel, Product $product)
|
||||
{
|
||||
$key = 'contingents_'.sha1($hotel->getUid().$product->getUid());
|
||||
|
||||
if (false === $contingents = $this->cache->get($key)) {
|
||||
$data = $this->contingentRepository->getAvailableContingents($hotel, $product);
|
||||
$contingents = [];
|
||||
foreach ($data as $row) {
|
||||
@@ -80,9 +67,6 @@ class ContingentDataService
|
||||
];
|
||||
}
|
||||
|
||||
$this->cache->set($key, $contingents, [], self::CACHE_TTL);
|
||||
}
|
||||
|
||||
return $contingents;
|
||||
}
|
||||
|
||||
@@ -100,11 +84,8 @@ class ContingentDataService
|
||||
string $dateTo,
|
||||
Hotel $hotel,
|
||||
Product $product,
|
||||
$template = 'base'
|
||||
string $template = 'base'
|
||||
) {
|
||||
$key = 'rooms_'.sha1($dateFrom.$dateTo.$hotel->getUid().$product->getUid());
|
||||
|
||||
if (false === $rooms = $this->cache->get($key)) {
|
||||
$data = $this->contingentRepository->getAvailableRooms($dateFrom, $dateTo, $hotel, $product);
|
||||
$period = new Period($dateFrom, $dateTo);
|
||||
$nights = $period->dateInterval()->format('%a');
|
||||
@@ -127,9 +108,6 @@ class ContingentDataService
|
||||
$rooms[] = $row;
|
||||
}
|
||||
|
||||
$this->cache->set($key, $rooms, [], self::CACHE_TTL);
|
||||
}
|
||||
|
||||
return $rooms;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,15 +33,12 @@ use EP\EpProducts\Domain\Repository\DateRepository;
|
||||
use EP\EpProducts\Domain\Repository\ProductRepository;
|
||||
use EP\EpProducts\Utility\BookingUrlUtility;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
|
||||
use TYPO3\CMS\Core\SingletonInterface;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
|
||||
|
||||
class DateService implements SingletonInterface
|
||||
{
|
||||
public const CACHE_TTL = 60 * 60;
|
||||
|
||||
/**
|
||||
* @var ProductRepository
|
||||
*/
|
||||
@@ -62,11 +59,6 @@ class DateService implements SingletonInterface
|
||||
*/
|
||||
protected $uriBuilder;
|
||||
|
||||
/**
|
||||
* @var FrontendInterface
|
||||
*/
|
||||
protected $cache;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
@@ -84,22 +76,19 @@ class DateService implements SingletonInterface
|
||||
* @param DateRepository $dateRepository
|
||||
* @param FilterService $filterService
|
||||
* @param UriBuilder $uriBuilder
|
||||
* @param FrontendInterface $cache
|
||||
*/
|
||||
public function __construct
|
||||
(
|
||||
ProductRepository $productRepository,
|
||||
DateRepository $dateRepository,
|
||||
FilterService $filterService,
|
||||
UriBuilder $uriBuilder,
|
||||
FrontendInterface $cache
|
||||
UriBuilder $uriBuilder
|
||||
)
|
||||
{
|
||||
$this->productRepository = $productRepository;
|
||||
$this->filterService = $filterService;
|
||||
$this->dateRepository = $dateRepository;
|
||||
$this->uriBuilder = $uriBuilder;
|
||||
$this->cache = $cache;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,19 +114,10 @@ class DateService implements SingletonInterface
|
||||
$filterSettings = $this->filterService->getNormalizedFilterSettings();
|
||||
}
|
||||
|
||||
$keyValues = $product->getUid().$hotel->getUid().serialize($filterSettings);
|
||||
$keyValues.= $date ? $date->getUid() : 0;
|
||||
$key = 'pricetable_'.sha1($keyValues);
|
||||
|
||||
if (false === $priceTableData = $this->cache->get($key)) {
|
||||
$priceTableData = $this->productRepository->getPricetable($product, $hotel, $filterSettings, $date);
|
||||
$this->cache->set($key, $priceTableData, ['ep_products'], self::CACHE_TTL);
|
||||
}
|
||||
|
||||
$nonBookableDateUids = GeneralUtility::trimExplode(',', $product->getNonBookableDates(), true);
|
||||
|
||||
return $this->preprocessPriceTable([
|
||||
'priceTableData' => $priceTableData,
|
||||
'priceTableData' => $this->productRepository->getPricetable($product, $hotel, $filterSettings, $date),
|
||||
'template' => $template,
|
||||
'paCode' => $paCode,
|
||||
'isDayTrip' => $product->isDaytrip(),
|
||||
@@ -174,13 +154,7 @@ class DateService implements SingletonInterface
|
||||
$filterSettings = $this->filterService->getNormalizedFilterSettings();
|
||||
}
|
||||
|
||||
$key = 'datestable_'.sha1($product->getUid().$hotel->getUid().serialize($filterSettings));
|
||||
if (false === $datesTableData = $this->cache->get($key)) {
|
||||
$datesTableData = $this->productRepository->getAvailableDates($product, $hotel, $filterSettings);
|
||||
$this->cache->set($key, $datesTableData, ['ep_products'], self::CACHE_TTL);
|
||||
}
|
||||
|
||||
return $datesTableData;
|
||||
return $this->productRepository->getAvailableDates($product, $hotel, $filterSettings);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -196,14 +170,8 @@ class DateService implements SingletonInterface
|
||||
|
||||
public function getEventPriceTable(Product $product, int $maxPax = 99, string $template = 'base'): array
|
||||
{
|
||||
$key = 'pricetable_'.sha1($product->getUid());
|
||||
if (false === $priceTableData = $this->cache->get($key)) {
|
||||
$priceTableData = $this->productRepository->getEventPriceTable($product);
|
||||
$this->cache->set($key, $priceTableData, ['ep_products'], self::CACHE_TTL);
|
||||
}
|
||||
|
||||
return $this->preprocessEventPriceTable([
|
||||
'priceTableData' => $priceTableData,
|
||||
'priceTableData' => $this->productRepository->getEventPriceTable($product),
|
||||
'maxPax' => $maxPax,
|
||||
'template' => $template,
|
||||
]);
|
||||
|
||||
@@ -29,13 +29,10 @@ namespace EP\EpProducts\Service;
|
||||
use EP\EpProducts\Domain\Model\Hotel;
|
||||
use EP\EpProducts\Domain\Repository\HotelRepository;
|
||||
use EP\EpProducts\Domain\Repository\ProductRepository;
|
||||
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
|
||||
use TYPO3\CMS\Core\SingletonInterface;
|
||||
|
||||
class ProductDataService implements SingletonInterface
|
||||
{
|
||||
public const CACHE_TTL = 60 * 60;
|
||||
|
||||
/**
|
||||
* @var ProductRepository
|
||||
*/
|
||||
@@ -56,11 +53,6 @@ class ProductDataService implements SingletonInterface
|
||||
*/
|
||||
protected $hotelImageService;
|
||||
|
||||
/**
|
||||
* @var FrontendInterface
|
||||
*/
|
||||
protected $cache;
|
||||
|
||||
/**
|
||||
* @param ProductRepository $productRepository
|
||||
* @param HotelRepository $hotelRepository
|
||||
@@ -71,14 +63,12 @@ class ProductDataService implements SingletonInterface
|
||||
ProductRepository $productRepository,
|
||||
HotelRepository $hotelRepository,
|
||||
HotelImageService $hotelImageService,
|
||||
ProductImageService $productImageService,
|
||||
FrontendInterface $cache
|
||||
ProductImageService $productImageService
|
||||
) {
|
||||
$this->productRepository = $productRepository;
|
||||
$this->hotelRepository = $hotelRepository;
|
||||
$this->productImageService = $productImageService;
|
||||
$this->hotelImageService = $hotelImageService;
|
||||
$this->cache = $cache;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,13 +78,8 @@ class ProductDataService implements SingletonInterface
|
||||
*/
|
||||
public function getTeaser(array $filterSettings): ?array
|
||||
{
|
||||
$key = 'teaser_group_'.sha1(serialize($filterSettings));
|
||||
|
||||
if (false === $teasers = $this->cache->get($key)) {
|
||||
$teaserData = $this->productRepository->getTeasers($filterSettings);
|
||||
$teasers = $this->preprocessTeasergroup($teaserData);
|
||||
$this->cache->set($key, $teasers, ['ep_products'], self::CACHE_TTL);
|
||||
}
|
||||
|
||||
if (0 === count($teasers)) {
|
||||
return null;
|
||||
@@ -112,13 +97,8 @@ class ProductDataService implements SingletonInterface
|
||||
*/
|
||||
public function getTeasergroup(array $filterSettings, array $excludedConceptUids = [], int $limit = 0): array
|
||||
{
|
||||
$key = 'teaser_group_'.sha1(serialize($filterSettings).serialize($excludedConceptUids));
|
||||
|
||||
if (false === $teasers = $this->cache->get($key)) {
|
||||
$teaserData = $this->productRepository->getTeasers($filterSettings, $excludedConceptUids);
|
||||
$teasers = $this->preprocessTeasergroup($teaserData);
|
||||
$this->cache->set($key, $teasers, ['ep_products'], self::CACHE_TTL);
|
||||
}
|
||||
|
||||
if ($limit > 0) {
|
||||
return \array_slice($teasers, 0, $limit);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
<onChange>reload</onChange>
|
||||
<config>
|
||||
<type>select</type>
|
||||
<renderType>selectSingle</renderType>
|
||||
<default>Pricetable->event</default>
|
||||
<items type="array">
|
||||
<numIndex index="1" type="array">
|
||||
|
||||
@@ -27,15 +27,3 @@ services:
|
||||
EP\EpProducts\Service\ProductImageService:
|
||||
arguments:
|
||||
$cache: '@cache.ep_cache'
|
||||
|
||||
EP\EpProducts\Service\DateService:
|
||||
arguments:
|
||||
$cache: '@cache.ep_cache'
|
||||
|
||||
EP\EpProducts\Service\ProductDataService:
|
||||
arguments:
|
||||
$cache: '@cache.ep_cache'
|
||||
|
||||
EP\EpProducts\Service\ContingentDataService:
|
||||
arguments:
|
||||
$cache: '@cache.ep_cache'
|
||||
|
||||
Reference in New Issue
Block a user