1
|
|
|
<?php |
2
|
|
|
namespace ApacheSolrForTypo3\Solr\ViewHelpers\Facet\Area; |
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\FacetCollection; |
18
|
|
|
use ApacheSolrForTypo3\Solr\ViewHelpers\AbstractSolrFrontendViewHelper; |
19
|
|
|
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; |
20
|
|
|
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Class PageBrowserRangeViewHelper |
24
|
|
|
* |
25
|
|
|
* @author Frans Saris <[email protected]> |
26
|
|
|
* @author Timo Hund <[email protected]> * |
27
|
|
|
* @package ApacheSolrForTypo3\Solr\ViewHelpers |
28
|
|
|
*/ |
29
|
|
|
class GroupViewHelper extends AbstractSolrFrontendViewHelper |
30
|
|
|
{ |
31
|
|
|
use CompileWithRenderStatic; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var bool |
35
|
|
|
*/ |
36
|
|
|
protected $escapeOutput = false; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Initializes the arguments |
40
|
|
|
*/ |
41
|
1 |
|
public function initializeArguments() |
42
|
|
|
{ |
43
|
1 |
|
parent::initializeArguments(); |
44
|
1 |
|
$this->registerArgument('facets', FacetCollection::class, 'The facets that should be filtered', true); |
45
|
1 |
|
$this->registerArgument('groupName', 'string', 'The groupName that should be shown', false, 'main'); |
46
|
1 |
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @param array $arguments |
50
|
|
|
* @param \Closure $renderChildrenClosure |
51
|
|
|
* @param RenderingContextInterface $renderingContext |
52
|
|
|
* @return string |
53
|
|
|
*/ |
54
|
24 |
|
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) |
55
|
|
|
{ |
56
|
|
|
/** @var $facets FacetCollection */ |
57
|
24 |
|
$facets = $arguments['facets']; |
58
|
24 |
|
$requiredGroup = isset($arguments['groupName']) ? $arguments['groupName'] : 'main'; |
59
|
24 |
|
$filtered = $facets->getByGroupName($requiredGroup); |
60
|
|
|
|
61
|
24 |
|
$templateVariableProvider = $renderingContext->getVariableProvider(); |
62
|
24 |
|
$templateVariableProvider->add('areaFacets', $filtered); |
63
|
24 |
|
$content = $renderChildrenClosure(); |
64
|
23 |
|
$templateVariableProvider->remove('areaFacets'); |
65
|
|
|
|
66
|
23 |
|
return $content; |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|