From c0c9799daf6f46594236e9b9e174e542379c2f1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Mon, 21 Mar 2022 10:02:34 +0100 Subject: [PATCH] Remove superflous plugin, adjust viewhelper to use exsiting plugin --- config/sites/ep-reisen/config.yaml | 37 +++++++------ .../TCA/Overrides/tt_content.php | 6 -- .../ext/ep_products/ext_localconf.php | 8 --- .../ViewHelpers/Uri/ProductViewHelper.php | 55 ++++++------------- .../Private/Partials/Product/Teaser.html | 4 +- .../FluidStyledContent/TeaserBookingLink.html | 1 - .../Private/Templates/Product/HotelList.html | 1 - 7 files changed, 37 insertions(+), 75 deletions(-) diff --git a/config/sites/ep-reisen/config.yaml b/config/sites/ep-reisen/config.yaml index 76ee914c..7c095d4e 100644 --- a/config/sites/ep-reisen/config.yaml +++ b/config/sites/ep-reisen/config.yaml @@ -99,6 +99,17 @@ routeEnhancers: extension: EpProducts plugin: product_detail routes: + - + routePath: '/detail/{product}' + _controller: 'Product::detail' + _arguments: + product: product + - + routePath: '/detail/{product}/{hotel}' + _controller: 'Product::detail' + _arguments: + product: product + hotel: hotel - routePath: '/detail/{product_uid}/{hotel_uid}' _controller: 'Product::detail' @@ -113,6 +124,14 @@ routeEnhancers: date_to: dateTo defaultController: 'Product::detail' aspects: + product: + type: PersistedAliasMapper + tableName: tx_epproducts_domain_model_product + routeFieldName: path_segment + hotel: + type: PersistedAliasMapper + tableName: tx_epproducts_domain_model_hotel + routeFieldName: path_segment product_uid: type: PersistedAliasMapper tableName: tx_epproducts_domain_model_product @@ -130,24 +149,6 @@ routeEnhancers: hotel_uid: \d+ date_from: '\d{4}\-\d{2}\-\d{2}' date_to: '\d{4}\-\d{2}\-\d{2}' - BookingLinkPlugin: - type: Extbase - extension: EpProducts - plugin: booking_link - limitToPages: - - 1846 - routes: - - - routePath: '/{product}' - _controller: 'Product::detail' - _arguments: - product: product - defaultController: 'Product::detail' - aspects: - product: - type: PersistedAliasMapper - tableName: tx_epproducts_domain_model_product - routeFieldName: path_segment ContingentsIcalPlugin: type: Extbase extension: EpProducts diff --git a/public/typo3conf/ext/ep_products/Configuration/TCA/Overrides/tt_content.php b/public/typo3conf/ext/ep_products/Configuration/TCA/Overrides/tt_content.php index 50523ca4..cbe627a4 100644 --- a/public/typo3conf/ext/ep_products/Configuration/TCA/Overrides/tt_content.php +++ b/public/typo3conf/ext/ep_products/Configuration/TCA/Overrides/tt_content.php @@ -23,12 +23,6 @@ call_user_func(function () { 'Produkt: Details' ); - \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin( - 'EP.EpProducts', - 'booking_link', - 'Buchungslink' - ); - \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin( 'EP.EpProducts', 'product_teasergroup', diff --git a/public/typo3conf/ext/ep_products/ext_localconf.php b/public/typo3conf/ext/ep_products/ext_localconf.php index 80c180b9..23fec922 100644 --- a/public/typo3conf/ext/ep_products/ext_localconf.php +++ b/public/typo3conf/ext/ep_products/ext_localconf.php @@ -69,14 +69,6 @@ $boot = function () { ] ); - \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( - 'EP.ep_products', - 'booking_link', - [ - 'Product' => 'detail,hotelList', - ] - ); - \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( 'EP.ep_products', 'product_teasergroup', diff --git a/public/typo3conf/ext/ep_theme/Classes/ViewHelpers/Uri/ProductViewHelper.php b/public/typo3conf/ext/ep_theme/Classes/ViewHelpers/Uri/ProductViewHelper.php index 974bf61a..6659f0f3 100644 --- a/public/typo3conf/ext/ep_theme/Classes/ViewHelpers/Uri/ProductViewHelper.php +++ b/public/typo3conf/ext/ep_theme/Classes/ViewHelpers/Uri/ProductViewHelper.php @@ -27,10 +27,6 @@ namespace EP\EpTheme\ViewHelpers\Uri; * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ -use EP\EpEvents\Domain\Model\Hotel; -use EP\EpProducts\Domain\Model\Product; -use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; @@ -45,10 +41,9 @@ class ProductViewHelper extends AbstractViewHelper $this->registerArgument('product', 'mixed', 'The product'); $this->registerArgument('hotel', 'array', 'The hotel'); + $this->registerArgument('forceHotelUid', 'bool', 'Whether to force link a hotel'); $this->registerArgument('dateFrom', 'string', 'Date to limit table on detail page by (Y-m-d)'); $this->registerArgument('dateTo', 'string', 'Date to limit table on detail page by (Y-m-d)'); - $this->registerArgument('forceHotelUid', 'bool', 'Whether to force link a hotel'); - $this->registerArgument('slug', 'string', 'Slug to append to resulting uri'); } /** @@ -61,56 +56,38 @@ class ProductViewHelper extends AbstractViewHelper array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext - ) - { + ) { $product = $arguments['product']; $hotel = $arguments['hotel']; - $linkArguments = null; - if ($arguments['forceHotelUid']) { + // Product detail page with forced hotel $linkArguments = [ 'product' => is_array($product) ? $product['uid'] : $product, 'hotel' => is_array($hotel) ? $hotel['uid'] : $hotel, ]; } elseif ($arguments['dateFrom'] || $arguments['dateTo']) { + // Product detail page with forced date range $linkArguments = [ 'dateFrom' => $arguments['dateFrom'], 'dateTo' => $arguments['dateTo'], ]; - } - - if (null !== $linkArguments) { - $targetPageUid = is_array($product) ? (int)$product['detailPage'] : $product->getDetailPage(); - $uri = $renderingContext - ->getControllerContext() - ->getUriBuilder() - ->reset() - ->setTargetPageUid($targetPageUid) - ->uriFor('detail', $linkArguments, 'Product', 'epproducts', 'product_detail') - ; } else { - /** @var ContentObjectRenderer $contentObject */ - $contentObject = GeneralUtility::makeInstance(ContentObjectRenderer::class); - if (is_array($product)) { - $param = $product['detailPage']; - } elseif (null !== $product) { - $param = $product->getUid(); - } else { - $param = null; - } - $uri = $contentObject->typoLink_URL( - [ - 'parameter' => $param, - ] - ); + // Default product detail page by product uid + $linkArguments = [ + 'product' => is_array($product) ? $product['uid'] : $product, + ]; } - if ($arguments['slug']) { - $uri .= $arguments['slug'].'/'; - } + $targetPageUid = is_array($product) ? (int)$product['detailPage'] : $product->getDetailPage(); - return $uri; + return $renderingContext + ->getControllerContext() + ->getUriBuilder() + ->reset() + ->setTargetPageUid($targetPageUid) + ->uriFor('detail', $linkArguments, 'Product', 'epproducts', 'product_detail') + ; } } diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Partials/Product/Teaser.html b/public/typo3conf/ext/ep_theme/Resources/Private/Partials/Product/Teaser.html index 3cc81cd2..917549f8 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Partials/Product/Teaser.html +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Partials/Product/Teaser.html @@ -12,7 +12,7 @@