1
|
|
|
<?php |
2
|
|
|
namespace ApacheSolrForTypo3\Solr\ViewHelpers; |
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\LastSearches\LastSearchesService; |
18
|
|
|
use ApacheSolrForTypo3\Solr\System\Configuration\ConfigurationManager; |
19
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
20
|
|
|
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Class LastSearchesViewHelper |
24
|
|
|
* |
25
|
|
|
* @author Rudy Gnodde <[email protected]> |
26
|
|
|
*/ |
27
|
|
|
class LastSearchesViewHelper extends AbstractSolrViewHelper |
28
|
|
|
{ |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var bool |
32
|
|
|
*/ |
33
|
|
|
protected $escapeChildren = false; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var bool |
37
|
|
|
*/ |
38
|
|
|
protected $escapeOutput = false; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @param array $arguments |
42
|
|
|
* @param \Closure $renderChildrenClosure |
43
|
|
|
* @param RenderingContextInterface $renderingContext |
44
|
|
|
* @return mixed|void |
45
|
|
|
*/ |
46
|
2 |
|
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) |
47
|
|
|
{ |
48
|
|
|
/** @var ConfigurationManager $configurationManager */ |
49
|
2 |
|
$configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class); |
50
|
2 |
|
$typoScriptConfiguration = $configurationManager->getTypoScriptConfiguration(); |
51
|
2 |
|
$lastSearchesService = GeneralUtility::makeInstance( |
52
|
2 |
|
LastSearchesService::class, |
53
|
2 |
|
$typoScriptConfiguration |
54
|
|
|
); |
55
|
2 |
|
$templateVariableContainer = $renderingContext->getVariableProvider(); |
56
|
2 |
|
$templateVariableContainer->add('lastSearches', $lastSearchesService->getLastSearches()); |
57
|
2 |
|
$output = $renderChildrenClosure(); |
58
|
2 |
|
$templateVariableContainer->remove('lastSearches'); |
59
|
2 |
|
return $output; |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|