timohund /
ext-solr
| 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 AbstractUriViewHelper |
||
| 27 | * |
||
| 28 | * @author Frans Saris <[email protected]> |
||
| 29 | * @author Timo Hund <[email protected]> |
||
| 30 | */ |
||
| 31 | abstract class AbstractUriViewHelper extends AbstractSolrFrontendViewHelper |
||
| 32 | { |
||
| 33 | use CompileWithRenderStatic; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @var SearchUriBuilder |
||
| 37 | */ |
||
| 38 | protected static $searchUriBuilder; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @param SearchUriBuilder $searchUriBuilder |
||
| 42 | */ |
||
| 43 | public function injectSearchUriBuilder(SearchUriBuilder $searchUriBuilder) |
||
| 44 | 39 | { |
|
| 45 | self::$searchUriBuilder = $searchUriBuilder; |
||
| 46 | 39 | } |
|
| 47 | 39 | ||
| 48 | /** |
||
| 49 | * @return SearchUriBuilder|object |
||
| 50 | */ |
||
| 51 | protected static function getSearchUriBuilder() |
||
| 52 | 40 | { |
|
| 53 | if (!isset(self::$searchUriBuilder)) { |
||
| 54 | 40 | $objectManager = GeneralUtility::makeInstance(ObjectManager::class); |
|
| 55 | 28 | self::$searchUriBuilder = $objectManager->get(SearchUriBuilder::class); |
|
| 56 | 28 | } |
|
| 57 | |||
| 58 | return self::$searchUriBuilder; |
||
| 59 | 40 | } |
|
| 60 | |||
| 61 | /** |
||
| 62 | * @param RenderingContextInterface $renderingContext |
||
| 63 | * @return mixed |
||
| 64 | */ |
||
| 65 | protected static function getUsedSearchRequestFromRenderingContext(RenderingContextInterface $renderingContext) { |
||
| 66 | 36 | $resultSet = static::getUsedSearchResultSetFromRenderingContext($renderingContext); |
|
| 67 | 36 | if (!$resultSet instanceof SearchResultSet) { |
|
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 68 | 36 | throw new \InvalidArgumentException("The variable resultSet need to be defined in the scope of " . static::class); |
|
| 69 | } |
||
| 70 | |||
| 71 | return $resultSet->getUsedSearchRequest(); |
||
| 72 | 36 | } |
|
| 73 | } |
||
| 74 |