1 | <?php |
||
22 | trait SearchControllerTrait { |
||
23 | |||
24 | use AbstractControllerTrait; |
||
25 | |||
26 | /** |
||
27 | * |
||
28 | * @var SearchService |
||
29 | */ |
||
30 | private $searchService; |
||
31 | |||
32 | |||
33 | private $availableFacets; |
||
34 | |||
35 | private $facetFormatter; |
||
36 | |||
37 | |||
38 | |||
39 | public function searchAction(Request $request) { |
||
87 | |||
88 | protected function getConfiguredUsedFacets(array $queryUsedFacets) { |
||
96 | |||
97 | /** |
||
98 | * Maximum number of suggestions which should be provided by the autocomplete action |
||
99 | * |
||
100 | * @return integer |
||
101 | */ |
||
102 | protected function getSuggestionCount() { |
||
105 | |||
106 | /** |
||
107 | * Prefix to store information in the session variable |
||
108 | * |
||
109 | * @return string |
||
110 | */ |
||
111 | protected function getSessionPrefix() { |
||
114 | |||
115 | /** |
||
116 | * Number of results which should be displayed per page |
||
117 | * |
||
118 | * @return integer |
||
119 | */ |
||
120 | protected function getResultsPerPage() { |
||
123 | |||
124 | protected function getTemplate() { |
||
127 | |||
128 | protected function getFacetFormatter() { |
||
132 | |||
133 | /** |
||
134 | * Returns an array of preselected facets (no facet selected is the default) |
||
135 | * |
||
136 | * @return string[string][] |
||
137 | */ |
||
138 | protected function getDefaultFacets() { |
||
142 | |||
143 | /** |
||
144 | * Returns an array of the available facets which should be offered the user as a filter |
||
145 | * |
||
146 | * @return string[] |
||
147 | */ |
||
148 | protected function getAvailableFacets() { |
||
152 | |||
153 | |||
154 | protected function initFacets() { |
||
170 | |||
171 | /** |
||
172 | * Fetches the searched facets from the session object |
||
173 | * |
||
174 | * @param SessionInterface $session |
||
175 | * @return string[string][] |
||
176 | */ |
||
177 | protected function getSearchFacets(SessionInterface $session) { |
||
181 | |||
182 | /** |
||
183 | * Sets the given search facets in the user's session |
||
184 | * |
||
185 | * @param SessionInterface $session |
||
186 | * @param string[string][] $facets |
||
187 | */ |
||
188 | protected function setSearchFacets(SessionInterface $session, $facets) { |
||
191 | |||
192 | /** |
||
193 | * Fetches the search term from the session object |
||
194 | * |
||
195 | * @param SessionInterface $session |
||
196 | * @return mixed |
||
197 | */ |
||
198 | protected function getSearchTerm(SessionInterface $session) { |
||
201 | |||
202 | /** |
||
203 | * Sets the given search term in the user's session |
||
204 | * |
||
205 | * @param SessionInterface $session |
||
206 | * @param string $term |
||
207 | */ |
||
208 | protected function setSearchTerm(SessionInterface $session, $term) { |
||
211 | |||
212 | /** |
||
213 | * Returns a JSON array of autocompletions for the given term. |
||
214 | * The term can be provided as a GET or POST paramater with the name <em>term</em> |
||
215 | * |
||
216 | * @param Request $request |
||
217 | * @return \Symfony\Component\HttpFoundation\JsonResponse |
||
218 | */ |
||
219 | public function autocompleteAction(Request $request) { |
||
223 | |||
224 | /** |
||
225 | * Provides an online help for the configured search service. |
||
226 | * If the search service has no online help defined a warning message will be displayed to the user. |
||
227 | * |
||
228 | * @param Request $request |
||
229 | * @return \Symfony\Component\HttpFoundation\Response |
||
230 | */ |
||
231 | public function onlineHelpAction(Request $request) { |
||
235 | |||
236 | /** |
||
237 | * Inits and returns the configured search service |
||
238 | * |
||
239 | * @return SearchService |
||
240 | */ |
||
241 | protected function getSearchService() { |
||
246 | } |
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: