1
|
|
|
<?php |
2
|
|
|
namespace ApacheSolrForTypo3\Solr\ViewHelpers\Uri\Facet; |
3
|
|
|
|
4
|
|
|
/* |
5
|
|
|
* This file is part of the TYPO3 CMS project. |
6
|
|
|
* |
7
|
|
|
* It is free software; you can redistribute it and/or modify it under |
8
|
|
|
* the terms of the GNU General Public License, either version 2 |
9
|
|
|
* of the License, or any later version. |
10
|
|
|
* |
11
|
|
|
* For the full copyright and license information, please read the |
12
|
|
|
* LICENSE.txt file that was distributed with this source code. |
13
|
|
|
* |
14
|
|
|
* The TYPO3 project - inspiring people to share! |
15
|
|
|
*/ |
16
|
|
|
|
17
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\AbstractFacet; |
18
|
|
|
use ApacheSolrForTypo3\Solr\ViewHelpers\Uri\AbstractUriViewHelper; |
19
|
|
|
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Class RemoveFacetViewHelper |
23
|
|
|
* |
24
|
|
|
* @author Frans Saris <[email protected]> |
25
|
|
|
* @author Timo Hund <[email protected]> |
26
|
|
|
*/ |
27
|
|
|
class RemoveFacetViewHelper extends AbstractUriViewHelper |
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* Initializes the arguments |
31
|
|
|
*/ |
32
|
|
|
public function initializeArguments() |
33
|
|
|
{ |
34
|
|
|
parent::initializeArguments(); |
35
|
|
|
$this->registerArgument('facet', AbstractFacet::class, 'The facet', true); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param array $arguments |
40
|
|
|
* @param \Closure $renderChildrenClosure |
41
|
|
|
* @param RenderingContextInterface $renderingContext |
42
|
|
|
* @return string |
43
|
|
|
* @throws \InvalidArgumentException |
44
|
|
|
*/ |
45
|
1 |
|
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) |
46
|
|
|
{ |
47
|
|
|
/** @var $facet AbstractFacet */ |
48
|
1 |
|
$facet = $arguments['facet']; |
49
|
1 |
|
$previousRequest = $facet->getResultSet()->getUsedSearchRequest(); |
50
|
1 |
|
$uri = self::getSearchUriBuilder($renderingContext)->getRemoveFacetUri($previousRequest, $facet->getName()); |
51
|
1 |
|
return $uri; |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|