|
1
|
|
|
<?php |
|
2
|
|
|
namespace ApacheSolrForTypo3\Solr\ViewHelpers\Uri; |
|
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\SearchResultSet; |
|
18
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\Uri\SearchUriBuilder; |
|
19
|
|
|
use ApacheSolrForTypo3\Solr\ViewHelpers\AbstractSolrFrontendViewHelper; |
|
20
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
21
|
|
|
use TYPO3\CMS\Extbase\Object\ObjectManager; |
|
22
|
|
|
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; |
|
23
|
|
|
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Class FacetAddOptionViewHelper |
|
27
|
|
|
* |
|
28
|
|
|
* @author Frans Saris <[email protected]> |
|
29
|
|
|
* @author Timo Hund <[email protected]> |
|
30
|
|
|
* @package ApacheSolrForTypo3\Solr\ViewHelpers\Uri |
|
31
|
|
|
*/ |
|
32
|
|
|
abstract class AbstractUriViewHelper extends AbstractSolrFrontendViewHelper |
|
33
|
|
|
{ |
|
34
|
|
|
use CompileWithRenderStatic; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @var SearchUriBuilder |
|
38
|
|
|
*/ |
|
39
|
|
|
protected static $searchUriBuilder; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @param SearchUriBuilder $searchUriBuilder |
|
43
|
|
|
*/ |
|
44
|
|
|
public function injectSearchUriBuilder(SearchUriBuilder $searchUriBuilder) |
|
45
|
|
|
{ |
|
46
|
|
|
self::$searchUriBuilder = $searchUriBuilder; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @return SearchUriBuilder|object |
|
51
|
|
|
*/ |
|
52
|
|
|
protected static function getSearchUriBuilder() |
|
53
|
|
|
{ |
|
54
|
|
|
if (!isset(self::$searchUriBuilder)) { |
|
55
|
|
|
$objectManager = GeneralUtility::makeInstance(ObjectManager::class); |
|
56
|
|
|
self::$searchUriBuilder = $objectManager->get(SearchUriBuilder::class); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
return self::$searchUriBuilder; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @param RenderingContextInterface $renderingContext |
|
64
|
|
|
* @return mixed |
|
65
|
|
|
*/ |
|
66
|
|
|
protected static function getUsedSearchRequestFromRenderingContext(RenderingContextInterface $renderingContext) { |
|
67
|
|
|
$resultSet = static::getUsedSearchResultSetFromRenderingContext($renderingContext); |
|
68
|
|
|
if (!$resultSet instanceof SearchResultSet) { |
|
69
|
|
|
throw new \InvalidArgumentException("The variable resultSet need to be defined in the scope of " . static::class); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
return $resultSet->getUsedSearchRequest(); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|