Remove superflous plugin, adjust viewhelper to use exsiting plugin

This commit is contained in:
Björn Fromme
2022-03-21 10:02:34 +01:00
parent 3d5cb31c8c
commit c0c9799daf
7 changed files with 37 additions and 75 deletions
+19 -18
View File
@@ -99,6 +99,17 @@ routeEnhancers:
extension: EpProducts extension: EpProducts
plugin: product_detail plugin: product_detail
routes: 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}' routePath: '/detail/{product_uid}/{hotel_uid}'
_controller: 'Product::detail' _controller: 'Product::detail'
@@ -113,6 +124,14 @@ routeEnhancers:
date_to: dateTo date_to: dateTo
defaultController: 'Product::detail' defaultController: 'Product::detail'
aspects: 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: product_uid:
type: PersistedAliasMapper type: PersistedAliasMapper
tableName: tx_epproducts_domain_model_product tableName: tx_epproducts_domain_model_product
@@ -130,24 +149,6 @@ routeEnhancers:
hotel_uid: \d+ hotel_uid: \d+
date_from: '\d{4}\-\d{2}\-\d{2}' date_from: '\d{4}\-\d{2}\-\d{2}'
date_to: '\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: ContingentsIcalPlugin:
type: Extbase type: Extbase
extension: EpProducts extension: EpProducts
@@ -23,12 +23,6 @@ call_user_func(function () {
'Produkt: Details' 'Produkt: Details'
); );
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'EP.EpProducts',
'booking_link',
'Buchungslink'
);
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin( \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'EP.EpProducts', 'EP.EpProducts',
'product_teasergroup', 'product_teasergroup',
@@ -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( \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'EP.ep_products', 'EP.ep_products',
'product_teasergroup', 'product_teasergroup',
@@ -27,10 +27,6 @@ namespace EP\EpTheme\ViewHelpers\Uri;
* This copyright notice MUST APPEAR in all copies of the script! * 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\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
@@ -45,10 +41,9 @@ class ProductViewHelper extends AbstractViewHelper
$this->registerArgument('product', 'mixed', 'The product'); $this->registerArgument('product', 'mixed', 'The product');
$this->registerArgument('hotel', 'array', 'The hotel'); $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('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('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, array $arguments,
\Closure $renderChildrenClosure, \Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext RenderingContextInterface $renderingContext
) ) {
{
$product = $arguments['product']; $product = $arguments['product'];
$hotel = $arguments['hotel']; $hotel = $arguments['hotel'];
$linkArguments = null;
if ($arguments['forceHotelUid']) { if ($arguments['forceHotelUid']) {
// Product detail page with forced hotel
$linkArguments = [ $linkArguments = [
'product' => is_array($product) ? $product['uid'] : $product, 'product' => is_array($product) ? $product['uid'] : $product,
'hotel' => is_array($hotel) ? $hotel['uid'] : $hotel, 'hotel' => is_array($hotel) ? $hotel['uid'] : $hotel,
]; ];
} elseif ($arguments['dateFrom'] || $arguments['dateTo']) { } elseif ($arguments['dateFrom'] || $arguments['dateTo']) {
// Product detail page with forced date range
$linkArguments = [ $linkArguments = [
'dateFrom' => $arguments['dateFrom'], 'dateFrom' => $arguments['dateFrom'],
'dateTo' => $arguments['dateTo'], '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 { } else {
/** @var ContentObjectRenderer $contentObject */ // Default product detail page by product uid
$contentObject = GeneralUtility::makeInstance(ContentObjectRenderer::class); $linkArguments = [
if (is_array($product)) { 'product' => is_array($product) ? $product['uid'] : $product,
$param = $product['detailPage']; ];
} elseif (null !== $product) {
$param = $product->getUid();
} else {
$param = null;
}
$uri = $contentObject->typoLink_URL(
[
'parameter' => $param,
]
);
} }
if ($arguments['slug']) { $targetPageUid = is_array($product) ? (int)$product['detailPage'] : $product->getDetailPage();
$uri .= $arguments['slug'].'/';
}
return $uri; return $renderingContext
->getControllerContext()
->getUriBuilder()
->reset()
->setTargetPageUid($targetPageUid)
->uriFor('detail', $linkArguments, 'Product', 'epproducts', 'product_detail')
;
} }
} }
@@ -12,7 +12,7 @@
<f:section name="TeaserImage"> <f:section name="TeaserImage">
<div class="relative{f:if(condition: landscape, then: ' sm:w-2/5')}"> <div class="relative{f:if(condition: landscape, then: ' sm:w-2/5')}">
<a href="{ep:uri.product(forceHotelUid: forceHotelUid, product: product, hotel: hotel, dateFrom: dateFrom, dateTo: dateTo, slug: slug)}{f:if(condition: referringPageUri, then: '?ref={referringPageUri -> f:format.urlencode()}')}" <a href="{ep:uri.product(forceHotelUid: forceHotelUid, product: product, hotel: hotel, dateFrom: dateFrom, dateTo: dateTo)}{f:if(condition: referringPageUri, then: '?ref={referringPageUri -> f:format.urlencode()}')}"
title="{region.name} {product.name} Details und Buchen"> title="{region.name} {product.name} Details und Buchen">
<f:if condition="{productImage}"> <f:if condition="{productImage}">
<f:then> <f:then>
@@ -56,7 +56,7 @@
</f:section> </f:section>
<f:section name="TeaserContent"> <f:section name="TeaserContent">
<a href="{ep:uri.product(forceHotelUid: forceHotelUid, product: product, hotel: hotel, dateFrom: dateFrom, dateTo: dateTo, slug: slug)}{f:if(condition: referringPageUri, then: '?ref={referringPageUri -> f:format.urlencode()}')}" <a href="{ep:uri.product(forceHotelUid: forceHotelUid, product: product, hotel: hotel, dateFrom: dateFrom, dateTo: dateTo)}{f:if(condition: referringPageUri, then: '?ref={referringPageUri -> f:format.urlencode()}')}"
title="{region.name} {product.name} Details und Buchen" title="{region.name} {product.name} Details und Buchen"
class="flex-1 flex flex-col space-y-1 px-2 py-4 md:p-4"> class="flex-1 flex flex-col space-y-1 px-2 py-4 md:p-4">
<div class="product-teaser__label-name"> <div class="product-teaser__label-name">
@@ -21,7 +21,6 @@
forceHotelUid: teaser.forceHotelUid, forceHotelUid: teaser.forceHotelUid,
dateFrom: dateFrom, dateFrom: dateFrom,
dateTo: dateTo, dateTo: dateTo,
slug: teaser.product.slug,
landscape: '{f:if(condition: \'{data.layout} == 2 || {data.layout} == 3\', then: 1, else: 0)}' landscape: '{f:if(condition: \'{data.layout} == 2 || {data.layout} == 3\', then: 1, else: 0)}'
}"/> }"/>
</f:if> </f:if>
@@ -27,7 +27,6 @@
concept: product.concept, concept: product.concept,
hotel: item.hotel, hotel: item.hotel,
product: product, product: product,
slug: product.slug,
country: product.country, country: product.country,
region: product.region, region: product.region,
productImage: item.hotel.images.original.0, productImage: item.hotel.images.original.0,