1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the TYPO3 CMS project. |
7
|
|
|
* |
8
|
|
|
* It is free software; you can redistribute it and/or modify it under |
9
|
|
|
* the terms of the GNU General Public License, either version 2 |
10
|
|
|
* of the License, or any later version. |
11
|
|
|
* |
12
|
|
|
* For the full copyright and license information, please read the |
13
|
|
|
* LICENSE.txt file that was distributed with this source code. |
14
|
|
|
* |
15
|
|
|
* The TYPO3 project - inspiring people to share! |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
namespace ApacheSolrForTypo3\Solr\ViewHelpers; |
19
|
|
|
|
20
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Grouping\GroupItem; |
21
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\SearchResultSet; |
22
|
|
|
use ApacheSolrForTypo3\Solr\Mvc\Controller\SolrControllerContext; |
23
|
|
|
use ApacheSolrForTypo3\Solr\System\Configuration\TypoScriptConfiguration; |
24
|
|
|
use InvalidArgumentException; |
25
|
|
|
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Class AbstractSolrFrontendViewHelper |
29
|
|
|
* |
30
|
|
|
* @author Frans Saris <[email protected]> |
31
|
|
|
* @author Timo Hund <[email protected]> |
32
|
|
|
*/ |
33
|
|
|
abstract class AbstractSolrFrontendViewHelper extends AbstractSolrViewHelper |
34
|
|
|
{ |
35
|
|
|
/** |
36
|
|
|
* @var SolrControllerContext|null |
37
|
|
|
*/ |
38
|
|
|
protected ?SolrControllerContext $controllerContext = null; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @return TypoScriptConfiguration|null |
42
|
|
|
*/ |
43
|
|
|
protected function getTypoScriptConfiguration(): ?TypoScriptConfiguration |
44
|
|
|
{ |
45
|
|
|
return $this->getControllerContext()->getTypoScriptConfiguration(); |
|
|
|
|
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @return SearchResultSet|null |
50
|
|
|
* @deprecated Will be removed with v12. |
51
|
|
|
*/ |
52
|
|
|
protected function getSearchResultSet(): ?SearchResultSet |
53
|
|
|
{ |
54
|
|
|
return $this->getControllerContext()->getSearchResultSet(); |
|
|
|
|
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @return SolrControllerContext |
59
|
|
|
* @throws InvalidArgumentException |
60
|
|
|
* @deprecated Will be removed with v12. |
61
|
|
|
*/ |
62
|
|
|
protected function getControllerContext(): SolrControllerContext |
63
|
|
|
{ |
64
|
|
|
$controllerContext = null; |
65
|
|
|
if (method_exists($this->renderingContext, 'getControllerContext')) { |
66
|
|
|
$controllerContext = $this->renderingContext->getControllerContext(); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
if (!$controllerContext instanceof SolrControllerContext) { |
70
|
|
|
throw new InvalidArgumentException('No valid SolrControllerContext found', 1512998673); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
return $controllerContext; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @param RenderingContextInterface $renderingContext |
78
|
|
|
* @return SearchResultSet|GroupItem|null |
79
|
|
|
*/ |
80
|
29 |
|
protected static function getUsedSearchResultSetFromRenderingContext( |
81
|
|
|
RenderingContextInterface $renderingContext |
82
|
|
|
) { |
83
|
29 |
|
return $renderingContext->getVariableProvider()->get('resultSet') |
84
|
29 |
|
?? $renderingContext->getControllerContext()->getSearchResultSet(); |
|
|
|
|
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.