Remove superflous plugin, adjust viewhelper to use exsiting plugin
This commit is contained in:
@@ -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')
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user