first commit

This commit is contained in:
Sven Wappler
2021-04-17 00:26:33 +02:00
commit 866c63cc63
813 changed files with 100696 additions and 0 deletions

View File

@@ -0,0 +1,79 @@
<?php
namespace WapplerSystems\Meilisearch\ViewHelpers\Uri;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use WapplerSystems\Meilisearch\Domain\Search\ResultSet\SearchResultSet;
use WapplerSystems\Meilisearch\Domain\Search\Uri\SearchUriBuilder;
use WapplerSystems\Meilisearch\Mvc\Controller\SolrControllerContext;
use WapplerSystems\Meilisearch\ViewHelpers\AbstractSolrFrontendViewHelper;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
/**
* Class AbstractUriViewHelper
*
* @author Frans Saris <frans@beech.it>
* @author Timo Hund <timo.hund@dkd.de>
*/
abstract class AbstractUriViewHelper extends AbstractSolrFrontendViewHelper
{
use CompileWithRenderStatic;
/**
* @var SearchUriBuilder
*/
protected static $searchUriBuilder;
/**
* @param SearchUriBuilder $searchUriBuilder
*/
public function injectSearchUriBuilder(SearchUriBuilder $searchUriBuilder)
{
self::$searchUriBuilder = $searchUriBuilder;
}
/**
* @param RenderingContextInterface|null $renderingContext
* @return SearchUriBuilder|object
*/
protected static function getSearchUriBuilder(RenderingContextInterface $renderingContext = null)
{
if (!isset(self::$searchUriBuilder)) {
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
self::$searchUriBuilder = $objectManager->get(SearchUriBuilder::class);
}
if ($renderingContext && method_exists($renderingContext, 'getControllerContext')) {
self::$searchUriBuilder->injectUriBuilder($renderingContext->getControllerContext()->getUriBuilder());
}
return self::$searchUriBuilder;
}
/**
* @param RenderingContextInterface $renderingContext
* @return mixed
*/
protected static function getUsedSearchRequestFromRenderingContext(RenderingContextInterface $renderingContext) {
$resultSet = static::getUsedSearchResultSetFromRenderingContext($renderingContext);
if (!$resultSet instanceof SearchResultSet) {
throw new \InvalidArgumentException("The variable resultSet need to be defined in the scope of " . static::class);
}
return $resultSet->getUsedSearchRequest();
}
}

View File

@@ -0,0 +1,102 @@
<?php
namespace WapplerSystems\Meilisearch\ViewHelpers\Uri\Facet;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use WapplerSystems\Meilisearch\Domain\Search\ResultSet\Facets\AbstractFacet;
use WapplerSystems\Meilisearch\Domain\Search\ResultSet\Facets\AbstractFacetItem;
use WapplerSystems\Meilisearch\Domain\Search\ResultSet\SearchResultSet;
use WapplerSystems\Meilisearch\ViewHelpers\Uri\AbstractUriViewHelper;
/**
* Class AbstractValueViewHelper
*
* @author Frans Saris <frans@beech.it>
* @author Timo Hund <timo.hund@dkd.de>
*/
abstract class AbstractValueViewHelper extends AbstractUriViewHelper
{
/**
* Initializes the arguments
*/
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('facet', AbstractFacet::class, 'The facet', false, null);
$this->registerArgument('facetName', 'string', 'The facet name', false, null);
$this->registerArgument('facetItem', AbstractFacetItem::class, 'The facet item', false, null);
$this->registerArgument('facetItemValue', 'string', 'The facet item', false, null);
$this->registerArgument('resultSet', SearchResultSet::class, 'The result set', false, null);
}
/**
* @param $arguments
* @return string
* @throws \InvalidArgumentException
*/
protected static function getValueFromArguments($arguments)
{
if (isset($arguments['facetItem'])) {
/** @var $facetItem AbstractFacetItem */
$facetItem = $arguments['facetItem'];
$facetValue = $facetItem->getUriValue();
} elseif (isset($arguments['facetItemValue'])) {
$facetValue = $arguments['facetItemValue'];
} else {
throw new \InvalidArgumentException('No facetItem was passed, please pass either facetItem or facetItemValue');
}
return $facetValue;
}
/**
* @param $arguments
* @return string
* @throws \InvalidArgumentException
*/
protected static function getNameFromArguments($arguments)
{
if (isset($arguments['facet'])) {
/** @var $facet AbstractFacet */
$facet = $arguments['facet'];
$facetName = $facet->getName();
} elseif (isset($arguments['facetName'])) {
$facetName = $arguments['facetName'];
} else {
throw new \InvalidArgumentException('No facet was passed, please pass either facet or facetName');
}
return $facetName;
}
/**
* @param $arguments
* @return string
* @throws \InvalidArgumentException
*/
protected static function getResultSetFromArguments($arguments)
{
if (isset($arguments['facet'])) {
/** @var $facet AbstractFacet */
$facet = $arguments['facet'];
$resultSet = $facet->getResultSet();
} elseif (isset($arguments['facetName'])) {
$resultSet = $arguments['resultSet'];
} else {
throw new \InvalidArgumentException('No facet was passed, please pass either facet or resultSet');
}
return $resultSet;
}
}

View File

@@ -0,0 +1,45 @@
<?php
namespace WapplerSystems\Meilisearch\ViewHelpers\Uri\Facet;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use WapplerSystems\Meilisearch\Domain\Search\ResultSet\SearchResultSet;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
/**
* Class AddFacetItemViewHelper
*
* @author Frans Saris <frans@beech.it>
* @author Timo Hund <timo.hund@dkd.de>
*/
class AddFacetItemViewHelper extends AbstractValueViewHelper
{
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return string
* @throws \InvalidArgumentException
*/
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
/** @var $resultSet SearchResultSet */
$name = self::getNameFromArguments($arguments);
$itemValue = self::getValueFromArguments($arguments);
$resultSet = self::getResultSetFromArguments($arguments);
$previousRequest = $resultSet->getUsedSearchRequest();
$uri = self::getSearchUriBuilder($renderingContext)->getAddFacetValueUri($previousRequest, $name, $itemValue);
return $uri;
}
}

View File

@@ -0,0 +1,41 @@
<?php
namespace WapplerSystems\Meilisearch\ViewHelpers\Uri\Facet;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use WapplerSystems\Meilisearch\ViewHelpers\Uri\AbstractUriViewHelper;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
/**
* Class RemoveAllFacetsViewHelper
*
* @author Frans Saris <frans@beech.it>
* @author Timo Hund <timo.hund@dkd.de>
*/
class RemoveAllFacetsViewHelper extends AbstractUriViewHelper
{
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return string
* @throws \InvalidArgumentException
*/
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
$previousRequest = static::getUsedSearchRequestFromRenderingContext($renderingContext);
$uri = self::getSearchUriBuilder($renderingContext)->getRemoveAllFacetsUri($previousRequest);
return $uri;
}
}

View File

@@ -0,0 +1,46 @@
<?php
namespace WapplerSystems\Meilisearch\ViewHelpers\Uri\Facet;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use WapplerSystems\Meilisearch\Domain\Search\ResultSet\SearchResultSet;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
/**
* Class RemoveFacetItemViewHelper
*
* @author Frans Saris <frans@beech.it>
* @author Timo Hund <timo.hund@dkd.de>
*/
class RemoveFacetItemViewHelper extends AbstractValueViewHelper
{
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return string
* @throws \InvalidArgumentException
*/
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
/** @var $resultSet SearchResultSet */
$name = self::getNameFromArguments($arguments);
$itemValue = self::getValueFromArguments($arguments);
$resultSet = self::getResultSetFromArguments($arguments);
$previousRequest = $resultSet->getUsedSearchRequest();
$uri = self::getSearchUriBuilder($renderingContext)->getRemoveFacetValueUri($previousRequest, $name, $itemValue);
return $uri;
}
}

View File

@@ -0,0 +1,53 @@
<?php
namespace WapplerSystems\Meilisearch\ViewHelpers\Uri\Facet;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use WapplerSystems\Meilisearch\Domain\Search\ResultSet\Facets\AbstractFacet;
use WapplerSystems\Meilisearch\ViewHelpers\Uri\AbstractUriViewHelper;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
/**
* Class RemoveFacetViewHelper
*
* @author Frans Saris <frans@beech.it>
* @author Timo Hund <timo.hund@dkd.de>
*/
class RemoveFacetViewHelper extends AbstractUriViewHelper
{
/**
* Initializes the arguments
*/
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('facet', AbstractFacet::class, 'The facet', true);
}
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return string
* @throws \InvalidArgumentException
*/
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
/** @var $facet AbstractFacet */
$facet = $arguments['facet'];
$previousRequest = $facet->getResultSet()->getUsedSearchRequest();
$uri = self::getSearchUriBuilder($renderingContext)->getRemoveFacetUri($previousRequest, $facet->getName());
return $uri;
}
}

View File

@@ -0,0 +1,46 @@
<?php
namespace WapplerSystems\Meilisearch\ViewHelpers\Uri\Facet;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use WapplerSystems\Meilisearch\Domain\Search\ResultSet\SearchResultSet;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
/**
* Class SetFacetItemViewHelper
*
* @author Frans Saris <frans@beech.it>
* @author Timo Hund <timo.hund@dkd.de>
*/
class SetFacetItemViewHelper extends AbstractValueViewHelper
{
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return string
* @throws \InvalidArgumentException
*/
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
/** @var $resultSet SearchResultSet */
$name = self::getNameFromArguments($arguments);
$itemValue = self::getValueFromArguments($arguments);
$resultSet = self::getResultSetFromArguments($arguments);
$previousRequest = $resultSet->getUsedSearchRequest();
$uri = self::getSearchUriBuilder($renderingContext)->getSetFacetValueUri($previousRequest, $name, $itemValue);
return $uri;
}
}

View File

@@ -0,0 +1,55 @@
<?php
namespace WapplerSystems\Meilisearch\ViewHelpers\Uri\Paginate;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use WapplerSystems\Meilisearch\Domain\Search\ResultSet\Grouping\GroupItem;
use WapplerSystems\Meilisearch\ViewHelpers\Uri\AbstractUriViewHelper;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
/**
* Class GroupItemPageViewHelper
*
* @author Frans Saris <frans@beech.it>
* @author Timo Hund <timo.hund@dkd.de>
*/
class GroupItemPageViewHelper extends AbstractUriViewHelper
{
/**
* Initializes the arguments
*/
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('page', 'int', 'The page', false, 0);
$this->registerArgument('groupItem', GroupItem::class, 'The group item', true);
}
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return string
*/
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
$page = $arguments['page'];
$groupItem = $arguments['groupItem'];
$previousRequest = static::getUsedSearchRequestFromRenderingContext($renderingContext);
$uri = self::getSearchUriBuilder($renderingContext)->getResultGroupItemPageUri($previousRequest, $groupItem, (int)$page);
return $uri;
}
}

View File

@@ -0,0 +1,52 @@
<?php
namespace WapplerSystems\Meilisearch\ViewHelpers\Uri\Paginate;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use WapplerSystems\Meilisearch\ViewHelpers\Uri\AbstractUriViewHelper;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
/**
* Class ResultPageViewHelper
*
* @author Frans Saris <frans@beech.it>
* @author Timo Hund <timo.hund@dkd.de>
*/
class ResultPageViewHelper extends AbstractUriViewHelper
{
/**
* Initializes the arguments
*/
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('page', 'int', 'The page', false, 0);
}
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return string
*/
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
$page = $arguments['page'];
$previousRequest = static::getUsedSearchRequestFromRenderingContext($renderingContext);
$uri = self::getSearchUriBuilder($renderingContext)->getResultPageUri($previousRequest, $page);
return $uri;
}
}

View File

@@ -0,0 +1,70 @@
<?php
namespace WapplerSystems\Meilisearch\ViewHelpers\Uri\Result;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use WapplerSystems\Meilisearch\Domain\Search\Highlight\SiteHighlighterUrlModifier;
use WapplerSystems\Meilisearch\Domain\Search\ResultSet\SearchResultSet;
use WapplerSystems\Meilisearch\ViewHelpers\AbstractSolrFrontendViewHelper;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
/**
* Class AddSearchWordListViewHelper
*
* @author Timo Hund <timo.hund@dkd.de>
*/
class AddSearchWordListViewHelper extends AbstractSolrFrontendViewHelper
{
use CompileWithRenderStatic;
/**
* Initializes the arguments
*/
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('url', 'string', 'The context searchResultSet', true);
$this->registerArgument('searchWords', 'string', 'The document to highlight', true);
$this->registerArgument('addNoCache', 'boolean', 'Should no_cache=1 be added or not', false, true);
$this->registerArgument('keepCHash', 'boolean', 'Should cHash be kept or not', false, false);
}
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return string
*/
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
$url = $arguments['url'];
/** @var $resultSet SearchResultSet */
$resultSet = self::getUsedSearchResultSetFromRenderingContext($renderingContext);
if (!$resultSet->getUsedSearchRequest()->getContextTypoScriptConfiguration()->getSearchResultsSiteHighlighting()) {
return $url;
}
$searchWords = $arguments['searchWords'];
$addNoCache = $arguments['addNoCache'];
$keepCHash = $arguments['keepCHash'];
/** @var $siteHighlighterUrlModifier SiteHighlighterUrlModifier */
$siteHighlighterUrlModifier = GeneralUtility::makeInstance(SiteHighlighterUrlModifier::class);
return $siteHighlighterUrlModifier->modify($url, $searchWords, $addNoCache, $keepCHash);
}
}

View File

@@ -0,0 +1,41 @@
<?php
namespace WapplerSystems\Meilisearch\ViewHelpers\Uri\Search;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use WapplerSystems\Meilisearch\ViewHelpers\Uri\AbstractUriViewHelper;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
/**
* Class CurrentSearchViewHelper
*
* @author Frans Saris <frans@beech.it>
* @author Timo Hund <timo.hund@dkd.de>
*/
class CurrentSearchViewHelper extends AbstractUriViewHelper
{
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return string
*/
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
$previousRequest = static::getUsedSearchRequestFromRenderingContext($renderingContext);
$uri = self::getSearchUriBuilder($renderingContext)->getCurrentSearchUri($previousRequest);
return $uri;
}
}

View File

@@ -0,0 +1,51 @@
<?php
namespace WapplerSystems\Meilisearch\ViewHelpers\Uri\Search;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use WapplerSystems\Meilisearch\ViewHelpers\Uri\AbstractUriViewHelper;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
/**
* Class StartNewSearchViewHelper
*
* @author Frans Saris <frans@beech.it>
* @author Timo Hund <timo.hund@dkd.de>
*/
class StartNewSearchViewHelper extends AbstractUriViewHelper
{
/**
* Initializes the arguments
*/
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('queryString', 'string', 'The query string', false, '');
}
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return string
*/
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
$queryString = $arguments['queryString'];
$previousRequest = static::getUsedSearchRequestFromRenderingContext($renderingContext);
$uri = self::getSearchUriBuilder($renderingContext)->getNewSearchUri($previousRequest, $queryString);
return $uri;
}
}

View File

@@ -0,0 +1,41 @@
<?php
namespace WapplerSystems\Meilisearch\ViewHelpers\Uri\Sorting;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use WapplerSystems\Meilisearch\ViewHelpers\Uri\AbstractUriViewHelper;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
/**
* Class RemoveSortingViewHelper
*
* @author Frans Saris <frans@beech.it>
* @author Timo Hund <timo.hund@dkd.de>
*/
class RemoveSortingViewHelper extends AbstractUriViewHelper
{
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return string
*/
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
$previousRequest = static::getUsedSearchRequestFromRenderingContext($renderingContext);
$uri = self::getSearchUriBuilder($renderingContext)->getRemoveSortingUri($previousRequest);
return $uri;
}
}

View File

@@ -0,0 +1,53 @@
<?php
namespace WapplerSystems\Meilisearch\ViewHelpers\Uri\Sorting;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use WapplerSystems\Meilisearch\ViewHelpers\Uri\AbstractUriViewHelper;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
/**
* Class SetSortingViewHelper
*
* @author Frans Saris <frans@beech.it>
* @author Timo Hund <timo.hund@dkd.de>
*/
class SetSortingViewHelper extends AbstractUriViewHelper
{
/**
* Initializes the arguments
*/
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('sortingName', 'string', 'The sortingName', true);
$this->registerArgument('sortingDirection', 'string', 'The sortingDirection', true);
}
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return string
*/
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
$sortingName = $arguments['sortingName'];
$sortingDirection = $arguments['sortingDirection'];
$previousRequest = static::getUsedSearchRequestFromRenderingContext($renderingContext);
$uri = self::getSearchUriBuilder($renderingContext)->getSetSortingUri($previousRequest, $sortingName, $sortingDirection);
return $uri;
}
}