1717
1818namespace ApacheSolrForTypo3 \Solr \ViewHelpers ;
1919
20+ use ApacheSolrForTypo3 \Solr \Domain \Search \ResultSet \SearchResultSet ;
21+ use ApacheSolrForTypo3 \Solr \System \Configuration \TypoScriptConfiguration ;
2022use ApacheSolrForTypo3 \Solr \System \Url \UrlHelper ;
2123use Psr \Http \Message \ServerRequestInterface ;
2224use TYPO3 \CMS \Core \Context \Exception \AspectNotFoundException ;
2325use TYPO3 \CMS \Core \Utility \ArrayUtility ;
2426use TYPO3 \CMS \Core \Utility \GeneralUtility ;
2527use TYPO3 \CMS \Extbase \Mvc \RequestInterface ;
2628use TYPO3 \CMS \Extbase \Mvc \Web \Routing \UriBuilder ;
27- use TYPO3 \CMS \Fluid \Core \Rendering \RenderingContext ;
2829use TYPO3Fluid \Fluid \Core \Variables \VariableProviderInterface ;
30+ use TYPO3Fluid \Fluid \Core \ViewHelper \AbstractTagBasedViewHelper ;
2931
30- /**
31- * Class SearchFormViewHelper
32- *
33- *
34- * @property RenderingContext $renderingContext
35- */
36- class SearchFormViewHelper extends AbstractSolrFrontendTagBasedViewHelper
32+ final class SearchFormViewHelper extends AbstractTagBasedViewHelper
3733{
34+ protected UriBuilder $ uriBuilder ;
35+
3836 protected $ tagName = 'form ' ;
3937
4038 protected $ escapeChildren = true ;
4139
4240 protected $ escapeOutput = false ;
4341
44- /**
45- * Constructor
46- */
47- public function __construct (
48- protected readonly UriBuilder $ uriBuilder ,
49- ) {
50- parent ::__construct ();
42+ public function injectUriBuilder (UriBuilder $ uriBuilder ): void
43+ {
44+ $ this ->uriBuilder = $ uriBuilder ;
5145 }
5246
53- /**
54- * Initialize arguments.
55- */
5647 public function initializeArguments (): void
5748 {
5849 parent ::initializeArguments ();
@@ -144,7 +135,7 @@ public function render(): string
144135 * Get the existing search parameters in an array
145136 * Returns an empty array if search.keepExistingParametersForNewSearches is not set
146137 */
147- protected function getExistingSearchParameters (): array
138+ private function getExistingSearchParameters (): array
148139 {
149140 $ searchParameters = [];
150141 if ($ this ->getTypoScriptConfiguration ()->getSearchKeepExistingParametersForNewSearches ()) {
@@ -162,7 +153,7 @@ protected function getExistingSearchParameters(): array
162153 /**
163154 * Translate the multidimensional array of existing arguments into a flat array of name-value pairs for the input tags
164155 */
165- protected function translateSearchParametersToInputTagAttributes (
156+ private function translateSearchParametersToInputTagAttributes (
166157 array $ arguments ,
167158 string $ nameAttributePrefix = '' ,
168159 ): array {
@@ -181,12 +172,12 @@ protected function translateSearchParametersToInputTagAttributes(
181172 return $ attributes ;
182173 }
183174
184- protected function getTemplateVariableContainer (): ?VariableProviderInterface
175+ private function getTemplateVariableContainer (): ?VariableProviderInterface
185176 {
186177 return $ this ->templateVariableContainer ;
187178 }
188179
189- protected function getQueryString (): string
180+ private function getQueryString (): string
190181 {
191182 $ resultSet = $ this ->getSearchResultSet ();
192183 if ($ resultSet === null ) {
@@ -195,7 +186,7 @@ protected function getQueryString(): string
195186 return trim ($ this ->getSearchResultSet ()->getUsedSearchRequest ()->getRawUserQuery ());
196187 }
197188
198- protected function getSuggestUrl (?array $ additionalFilters , int $ pageUid ): string
189+ private function getSuggestUrl (?array $ additionalFilters , int $ pageUid ): string
199190 {
200191 $ pluginNamespace = $ this ->getTypoScriptConfiguration ()->getSearchPluginNamespace ();
201192 $ suggestUrl = $ this ->uriBuilder
@@ -210,7 +201,7 @@ protected function getSuggestUrl(?array $additionalFilters, int $pageUid): strin
210201 return $ urlService ->withoutQueryParameter ('cHash ' )->__toString ();
211202 }
212203
213- protected function buildUriFromPageUidAndArguments (int $ pageUid ): string
204+ private function buildUriFromPageUidAndArguments (int $ pageUid ): string
214205 {
215206 return $ this ->uriBuilder
216207 ->reset ()
@@ -224,4 +215,14 @@ protected function buildUriFromPageUidAndArguments(int $pageUid): string
224215 ->setSection ($ this ->arguments ['section ' ] ?? '' )
225216 ->build ();
226217 }
218+
219+ private function getTypoScriptConfiguration (): TypoScriptConfiguration
220+ {
221+ return $ this ->renderingContext ->getVariableProvider ()->get ('typoScriptConfiguration ' );
222+ }
223+
224+ private function getSearchResultSet (): ?SearchResultSet
225+ {
226+ return $ this ->renderingContext ->getVariableProvider ()->get ('searchResultSet ' );
227+ }
227228}
0 commit comments