Completed
Pull Request — master (#1346)
by Timo
33:05
created

QueryViewHelper::renderStatic()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.2
c 0
b 0
f 0
cc 4
eloc 6
nc 2
nop 3
1
<?php
2
namespace ApacheSolrForTypo3\Solr\ViewHelpers\Debug;
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\ViewHelpers\AbstractSolrFrontendViewHelper;
18
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
19
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
20
21
/**
22
 * Class QueryViewHelper
23
 *
24
 * @author Frans Saris <[email protected]>
25
 * @author Timo Hund <[email protected]>
26
 */
27
class QueryViewHelper extends AbstractSolrFrontendViewHelper
28
{
29
    use CompileWithRenderStatic;
30
31
    /**
32
     * @var bool
33
     */
34
    protected $escapeOutput = false;
35
36
    /**
37
     * @param array $arguments
38
     * @param \Closure $renderChildrenClosure
39
     * @param RenderingContextInterface $renderingContext
40
     * @return string
41
     */
42
    public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
43
    {
44
        $content = '';
45
        $resultSet = self::getUsedSearchResultSetFromRenderingContext($renderingContext);
46
        if (!empty($GLOBALS['TSFE']->beUserLogin) && $resultSet && $resultSet->getUsedSearch() !== null) {
47
            $content = '<br><strong>Parsed Query:</strong><br>' . $resultSet->getUsedSearch()->getDebugResponse()->parsedquery;
48
        }
49
        return $content;
50
    }
51
}
52