public function SearchViewController::get in Google Search Appliance 8
Builds search page.
Parameters
\Symfony\Component\HttpFoundation\Request $request: Current request.
string $search_query: Search query.
null|string $result_sort: Sort order.
Return value
array Render array
File
- src/
Controller/ SearchViewController.php, line 63
Class
- SearchViewController
- Class SearchView.
Namespace
Drupal\google_appliance\ControllerCode
public function get(Request $request, $search_query = '', $result_sort = NULL) {
$search_query = urldecode($search_query);
$form = $this->formBuilder
->getForm(SearchForm::class, $search_query);
if ($search_query !== '' && !$request->request
->has('form_id')) {
// @todo Language filter.
$response = $this->search
->search(new SearchQuery($search_query, $result_sort === 'date' ? SearchQuery::ORDER_DATE : NULL, $request->query
->get('page')));
return [
'#theme' => 'google_appliance_search_results',
'#results' => $response,
'#form' => $form,
'#cache' => [
'tags' => [
'config:google_appliance.settings',
],
],
];
}
return $form;
}