|
|
|
@@ -5,15 +5,23 @@ namespace EP\EpProducts\Service;
|
|
|
|
|
use EP\EpProducts\Domain\Model\Hotel;
|
|
|
|
|
use EP\EpProducts\Domain\Model\Product;
|
|
|
|
|
use EP\EpProducts\Domain\Repository\DateRepository;
|
|
|
|
|
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Lists the pickup points of a product's latest upcoming date that has any,
|
|
|
|
|
* with that date's time and round-trip surcharge per pickup point. Pickups,
|
|
|
|
|
* times and prices may differ on other dates; taking the latest one keeps the
|
|
|
|
|
* values unique and shows them for as long as the product is offered.
|
|
|
|
|
* Lists the pickup points of a product's latest upcoming end-customer date that
|
|
|
|
|
* has any, with that date's time and round-trip surcharge per pickup point.
|
|
|
|
|
* Group travel dates are left out: their pickups are arranged per group and
|
|
|
|
|
* are not offered publicly. Pickups, times and prices may differ on other
|
|
|
|
|
* dates; taking the latest one keeps the values unique and shows them for as
|
|
|
|
|
* long as the product is offered.
|
|
|
|
|
*
|
|
|
|
|
* The returned shape is meant to be served by MyE&P later on, so that only the
|
|
|
|
|
* data source has to change once the local date table goes away.
|
|
|
|
|
*
|
|
|
|
|
* Switched by pickupsOverviewEnabled in the extension configuration. A missing
|
|
|
|
|
* key means off: a key added to ext_conf_template.txt is absent until the
|
|
|
|
|
* extension configuration is saved in the backend, and the overview must not
|
|
|
|
|
* go live before it is approved.
|
|
|
|
|
*/
|
|
|
|
|
class PickupOverviewService
|
|
|
|
|
{
|
|
|
|
@@ -22,9 +30,16 @@ class PickupOverviewService
|
|
|
|
|
*/
|
|
|
|
|
private $dateRepository;
|
|
|
|
|
|
|
|
|
|
public function __construct(DateRepository $dateRepository)
|
|
|
|
|
/**
|
|
|
|
|
* @var bool
|
|
|
|
|
*/
|
|
|
|
|
private $enabled;
|
|
|
|
|
|
|
|
|
|
public function __construct(DateRepository $dateRepository, ExtensionConfiguration $extensionConfiguration)
|
|
|
|
|
{
|
|
|
|
|
$this->dateRepository = $dateRepository;
|
|
|
|
|
$configuration = (array) $extensionConfiguration->get('ep_products');
|
|
|
|
|
$this->enabled = (bool) ($configuration['pickupsOverviewEnabled'] ?? false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@@ -33,7 +48,7 @@ class PickupOverviewService
|
|
|
|
|
public function getOverview(Product $product, ?Hotel $hotel): array
|
|
|
|
|
{
|
|
|
|
|
$overview = ['pickups' => []];
|
|
|
|
|
if ($hotel === null || $product->isDaytrip()) {
|
|
|
|
|
if (!$this->enabled || $hotel === null || $product->isDaytrip()) {
|
|
|
|
|
return $overview;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|