1 | <?php |
||
25 | trait SearchControllerTrait { |
||
26 | |||
27 | /** |
||
28 | * @var SearchService |
||
29 | */ |
||
30 | protected $searchService; |
||
31 | private $availableFacets; |
||
32 | private $facetFormatter; |
||
33 | |||
34 | public function searchAction(Request $request, DocumentToEntityMapperInterface $mapper) { |
||
91 | |||
92 | /** |
||
93 | * Returns a JSON array of autocompletions for the given term. |
||
94 | * The term can be provided as a GET or POST paramater with the name <em>term</em> |
||
95 | * |
||
96 | * @param Request $request |
||
97 | * @return \Symfony\Component\HttpFoundation\JsonResponse |
||
98 | */ |
||
99 | public function autocompleteAction(Request $request) { |
||
103 | |||
104 | /** |
||
105 | * Provides an online help for the configured search service. |
||
106 | * If the search service has no online help defined a warning message will be displayed to the user. |
||
107 | * |
||
108 | * @param Request $request |
||
109 | * @return \Symfony\Component\HttpFoundation\Response |
||
110 | */ |
||
111 | public function onlineHelpAction(Request $request) { |
||
115 | |||
116 | /** |
||
117 | * @param SearchService $searchService |
||
118 | * @required |
||
119 | */ |
||
120 | public function setSearchService(SearchService $searchService): void { |
||
123 | |||
124 | protected function getConfiguredUsedFacets(array $queryUsedFacets) { |
||
132 | |||
133 | /** |
||
134 | * Maximum number of suggestions which should be provided by the autocomplete action |
||
135 | * |
||
136 | * @return integer |
||
137 | */ |
||
138 | protected function getSuggestionCount() { |
||
141 | |||
142 | /** |
||
143 | * Prefix to store information in the session variable |
||
144 | * |
||
145 | * @return string |
||
146 | */ |
||
147 | protected function getSessionPrefix() { |
||
150 | |||
151 | /** |
||
152 | * Number of results which should be displayed per page |
||
153 | * |
||
154 | * @return integer |
||
155 | */ |
||
156 | protected function getResultsPerPage() { |
||
159 | |||
160 | protected function getTemplate() { |
||
163 | |||
164 | protected function getErrorTemplate() { |
||
167 | |||
168 | protected function getFacetFormatter() { |
||
172 | |||
173 | /** |
||
174 | * Returns an array of preselected facets (no facet selected is the default) |
||
175 | * |
||
176 | * @return string[string][] |
||
177 | */ |
||
178 | protected function getDefaultFacets() { |
||
182 | |||
183 | /** |
||
184 | * Returns an array of the available facets which should be offered the user as a filter |
||
185 | * |
||
186 | * @return string[] |
||
187 | */ |
||
188 | protected function getAvailableFacets() { |
||
192 | |||
193 | protected function initFacets() { |
||
208 | |||
209 | /** |
||
210 | * Fetches the searched facets from the session object |
||
211 | * |
||
212 | * @param SessionInterface $session |
||
213 | * @return string[string][] |
||
214 | */ |
||
215 | protected function getSearchFacets(SessionInterface $session) { |
||
219 | |||
220 | /** |
||
221 | * Sets the given search facets in the user's session |
||
222 | * |
||
223 | * @param SessionInterface $session |
||
224 | * @param string[string][] $facets |
||
225 | */ |
||
226 | protected function setSearchFacets(SessionInterface $session, $facets) { |
||
229 | |||
230 | /** |
||
231 | * Fetches the search term from the session object |
||
232 | * |
||
233 | * @param SessionInterface $session |
||
234 | * @return mixed |
||
235 | */ |
||
236 | protected function getSearchTerm(SessionInterface $session) { |
||
239 | |||
240 | /** |
||
241 | * Sets the given search term in the user's session |
||
242 | * |
||
243 | * @param SessionInterface $session |
||
244 | * @param string $term |
||
245 | */ |
||
246 | protected function setSearchTerm(SessionInterface $session, $term) { |
||
249 | |||
250 | } |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: