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,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;
}
}