function search_api_autocomplete_views_query in Search API Autocomplete 7
Create the query that would be issued for the given search for the complete keys.
Parameters
SearchApiAutocompleteSearch $search: The search for which to create the query.
$complete: A string containing the complete search keys.
$incomplete: A string containing the incomplete last search key.
Return value
SearchApiQueryInterface The query that would normally be executed when only $complete was entered as the search keys for the given search.
Throws
SearchApiException If the query couldn't be created.
1 string reference to 'search_api_autocomplete_views_query'
File
- ./
search_api_autocomplete.search_api_views.inc, line 96 - Contains code for integrating with the "Search views" module.
Code
function search_api_autocomplete_views_query(SearchApiAutocompleteSearch $search, $complete, $incomplete) {
$views_id = substr($search->machine_name, 17);
$view = views_get_view($views_id);
if (!$view) {
$vars['@view'] = $views_id;
throw new SearchApiException(t('Could not load view @view.', $vars));
}
$view
->set_display(isset($search->options['custom']['display']) ? $search->options['custom']['display'] : NULL);
$view
->pre_execute();
$view
->build();
$query = $view->query
->getSearchApiQuery();
if (!$query) {
$vars['@view'] = !empty($view->human_name) ? $view->human_name : $views_id;
throw new SearchApiException(t('Could not create query for view @view.', $vars));
}
$query
->keys($complete);
return $query;
}