public function SearchPluginBase::buildSearchUrlQuery in Drupal 9
Same name and namespace in other branches
- 8 core/modules/search/src/Plugin/SearchPluginBase.php \Drupal\search\Plugin\SearchPluginBase::buildSearchUrlQuery()
Builds the URL GET query parameters array for search.
When the search form is submitted, a redirect is generated with the search input as GET query parameters. Plugins using the searchFormAlter() method to add form elements to the search form will need to override this method to gather the form input and add it to the GET query parameters.
Parameters
\Drupal\Core\Form\FormStateInterface $form_state: The form state, with submitted form information.
Return value
array An array of GET query parameters containing all relevant form values to process the search. The 'keys' element must be present in order to trigger generation of search results, even if it is empty or unused by the search plugin.
Overrides SearchInterface::buildSearchUrlQuery
See also
SearchInterface::searchFormAlter()
1 method overrides SearchPluginBase::buildSearchUrlQuery()
- NodeSearch::buildSearchUrlQuery in core/
modules/ node/ src/ Plugin/ Search/ NodeSearch.php - Builds the URL GET query parameters array for search.
File
- core/
modules/ search/ src/ Plugin/ SearchPluginBase.php, line 135
Class
- SearchPluginBase
- Defines a base class for plugins wishing to support search.
Namespace
Drupal\search\PluginCode
public function buildSearchUrlQuery(FormStateInterface $form_state) {
// Grab the keywords entered in the form and put them as 'keys' in the GET.
$keys = trim($form_state
->getValue('keys'));
$query = [
'keys' => $keys,
];
return $query;
}