Passed
Push — task/2976_TYPO3.11_compatibili... ( d7dfd0...4be1cc )
by Rafael
03:40
created

LastSearchesViewHelper   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 13
dl 0
loc 33
ccs 11
cts 11
cp 1
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A renderStatic() 0 14 1
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