diff --git a/config/sites/ep-reisen/config.yaml b/config/sites/ep-reisen/config.yaml index 975adc56..2d4683cc 100644 --- a/config/sites/ep-reisen/config.yaml +++ b/config/sites/ep-reisen/config.yaml @@ -173,16 +173,26 @@ routeEnhancers: - 2712 routes: - - routePath: '/{travelinfo}' + routePath: '/{travelinfo}/{traveldate}' _controller: 'Travelinfo::index' _arguments: travelinfo: travelinfo + traveldate: travelDate + - + routePath: '/{busproid}' + _controller: 'Travelinfo::myep' + _arguments: + busproid: busProId defaultController: 'Travelinfo::index' aspects: travelinfo: type: PersistedAliasMapper tableName: tx_epproducts_domain_model_travelinfo routeFieldName: path_segment + traveldate: + type: PassthroughMapper + busproid: + type: PassthroughMapper ContingentsIcalPlugin: type: Extbase extension: EpProducts diff --git a/public/typo3conf/ext/ep_products/Classes/Controller/TravelinfoController.php b/public/typo3conf/ext/ep_products/Classes/Controller/TravelinfoController.php index 9369b93b..e719e6ee 100644 --- a/public/typo3conf/ext/ep_products/Classes/Controller/TravelinfoController.php +++ b/public/typo3conf/ext/ep_products/Classes/Controller/TravelinfoController.php @@ -2,8 +2,10 @@ namespace EP\EpProducts\Controller; +use EP\EpProducts\Domain\Model\Date; use EP\EpProducts\Domain\Model\Travelinfo; use EP\EpProducts\Domain\Repository\DateRepository; +use EP\EpProducts\Domain\Repository\TravelInfoRepository; use TYPO3\CMS\Core\Http\ImmediateResponseException; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; @@ -16,24 +18,49 @@ class TravelinfoController extends ActionController */ private $dateRepository; - public function __construct(DateRepository $dateRepository) + /** + * @var TravelInfoRepository + */ + private $travelInfoRepository; + + public function __construct(DateRepository $dateRepository, TravelInfoRepository $travelInfoRepository) { $this->dateRepository = $dateRepository; + $this->travelInfoRepository = $travelInfoRepository; } - public function indexAction(Travelinfo $travelinfo) + public function myepAction(int $busProId) { - $today = new \DateTimeImmutable(); - $date = $this->dateRepository->findOneByCode($travelinfo->getTravelCode()); + /** @var Date $date */ + $date = $this->dateRepository->findOneByBusProId($busProId); + $travelinfo = $this->travelInfoRepository->findOneByProduct($date->getProduct()); - if (null === $date || $date->getDateEnd() < $today) { + if (null === $travelinfo) { $response = GeneralUtility::makeInstance(ErrorController::class)->pageNotFoundAction( $GLOBALS['TYPO3_REQUEST'], - 'Reiseinformationen nicht gefunden oder Termin abgelaufen' + 'Reiseinformationen nicht gefunden' ); throw new ImmediateResponseException($response, 1731071856); } + $this->redirect( + 'index', + null, + null, + [ + 'travelinfo' => $travelinfo, + 'travelDate' => $date->getDateStart()->format('Y-m-d'), + ] + ); + } + + public function indexAction(Travelinfo $travelinfo, string $travelDate) + { + $product = $travelinfo->getProduct(); + + /** @var Date $date */ + $date = $this->dateRepository->findForProductAndDate($product, $travelDate)->getFirst(); + $this->view->assign('travelinfo', $travelinfo); $this->view->assign('date', $date); } diff --git a/public/typo3conf/ext/ep_products/Classes/Domain/Model/Travelinfo.php b/public/typo3conf/ext/ep_products/Classes/Domain/Model/Travelinfo.php index 1e68c7fa..d81545ae 100644 --- a/public/typo3conf/ext/ep_products/Classes/Domain/Model/Travelinfo.php +++ b/public/typo3conf/ext/ep_products/Classes/Domain/Model/Travelinfo.php @@ -79,6 +79,16 @@ class Travelinfo extends AbstractEntity */ protected $travelCode; + /** + * @var Product + */ + protected $product; + + /** + * @var bool + */ + protected $hideAddress = false; + public function __construct() { $this->initStorageObjects(); @@ -259,5 +269,27 @@ class Travelinfo extends AbstractEntity return $this; } + + public function getProduct() + { + return $this->product; + } + + public function setProduct($product) + { + $this->product = $product; + return $this; + } + + public function isHideAddress() + { + return $this->hideAddress; + } + + public function setHideAddress($hideAddress) + { + $this->hideAddress = $hideAddress; + return $this; + } } diff --git a/public/typo3conf/ext/ep_products/Classes/Domain/Repository/DateRepository.php b/public/typo3conf/ext/ep_products/Classes/Domain/Repository/DateRepository.php index a1d5f80b..145fc725 100644 --- a/public/typo3conf/ext/ep_products/Classes/Domain/Repository/DateRepository.php +++ b/public/typo3conf/ext/ep_products/Classes/Domain/Repository/DateRepository.php @@ -2,5 +2,20 @@ namespace EP\EpProducts\Domain\Repository; +use EP\EpProducts\Domain\Model\Product; + class DateRepository extends AbstractRepository -{} +{ + public function findForProductAndDate(Product $product, string $date) + { + $query = $this->createQuery(); + + return $query + ->matching($query->logicalAnd([ + $query->equals('product', $product), + $query->equals('dateStart', $date), + ])) + ->execute() + ; + } +} diff --git a/public/typo3conf/ext/ep_products/Classes/Domain/Repository/TravelInfoRepository.php b/public/typo3conf/ext/ep_products/Classes/Domain/Repository/TravelInfoRepository.php new file mode 100644 index 00000000..7e0a756e --- /dev/null +++ b/public/typo3conf/ext/ep_products/Classes/Domain/Repository/TravelInfoRepository.php @@ -0,0 +1,6 @@ + [ - 'basics' => ['showitem' => 'title,path_segment,--linebreak--,travel_code,--linebreak--,links,--linebreak--,teasers'], + 'basics' => ['showitem' => 'title,path_segment,--linebreak--,product,hide_address,--linebreak--,links, + --linebreak--,teasers'], 'text' => ['showitem' => 'subline,headline,--linebreak--,intro_text,--linebreak--,footer_text,--linebreak--, self_arranged_text,--linebreak--,additional_info,--linebreak--,important_phone_numbers,--linebreak--, important_links'], @@ -190,13 +191,39 @@ return [ $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] ), ], - 'travel_code' => [ + 'product' => [ 'exclude' => false, - 'label' => 'Reisecode des Termins', + 'label' => 'Produkt', 'config' => [ - 'type' => 'input', - 'size' => 30, - 'eval' => 'trim,required' + 'type' => 'group', + 'internal_type' => 'db', + 'allowed' => 'tx_epproducts_domain_model_product', + 'minitems' => 1, + 'maxitems' => 1, + 'size' => 1, + 'fieldControl' => [ + 'elementBrowser' => [ + 'disabled' => true, + ], + ], + 'fieldWizard' => [ + 'recordsOverview' => [ + 'disabled' => true, + ], + ], + 'suggestOptions' => [ + 'default' => [ + 'additionalSearchFields' => 'code,name,keywords', + 'orderBy' => 'code', + ], + ], + ], + ], + 'hide_address' => [ + 'exclude' => 0, + 'label' => 'Adresse ausblenden', + 'config' => [ + 'type' => 'check', ], ], 'intro_text' => [ diff --git a/public/typo3conf/ext/ep_products/ext_localconf.php b/public/typo3conf/ext/ep_products/ext_localconf.php index 5abd3536..97c5ad49 100644 --- a/public/typo3conf/ext/ep_products/ext_localconf.php +++ b/public/typo3conf/ext/ep_products/ext_localconf.php @@ -252,7 +252,7 @@ $boot = function () { 'EP.ep_products', 'travelinfo', [ - 'Travelinfo' => 'index', + 'Travelinfo' => 'index,myep', ] ); diff --git a/public/typo3conf/ext/ep_products/ext_tables.sql b/public/typo3conf/ext/ep_products/ext_tables.sql index 9aab062e..17827f32 100644 --- a/public/typo3conf/ext/ep_products/ext_tables.sql +++ b/public/typo3conf/ext/ep_products/ext_tables.sql @@ -1370,6 +1370,8 @@ CREATE TABLE tx_epproducts_domain_model_travelinfo footer_image int(11) DEFAULT '0' NOT NULL, links int(11) DEFAULT '0' NOT NULL, teasers int(11) DEFAULT '0' NOT NULL, + product int(11) unsigned DEFAULT '0', + hide_address tinyint(4) unsigned DEFAULT '0' NOT NULL, travel_code varchar(255) DEFAULT '' NOT NULL, path_segment varchar(255) DEFAULT '' NOT NULL, diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Travelinfo/Index.html b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Travelinfo/Index.html index 07b82f9b..9de8c6c5 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Travelinfo/Index.html +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Travelinfo/Index.html @@ -12,8 +12,8 @@ alt="Reiseinformationen" class="block w-full h-full object-cover object-center" /> -
- {date.hotel.name}
-
- {date.hotel.address -> f:format.nl2br()}
-
+ {date.hotel.name}
+
+ {date.hotel.address -> f:format.nl2br()}
+