You are here

function apachesolr_autocomplete_invoke in Apache Solr Autocomplete 7.2

Given a set of keys, invoke all the available autocomplete engines and build an array of suggestions.

Parameters

$keys: String to autocomplete on.

$context: Configuration to build the autocomplete.

Return value

array List of suggestions.

1 call to apachesolr_autocomplete_invoke()
apachesolr_autocomplete_callback in ./apachesolr_autocomplete.module
Callback for url apachesolr_autocomplete/autocomplete.

File

./apachesolr_autocomplete.module, line 220
Alters search forms to suggest terms using Apache Solr using AJAX.

Code

function apachesolr_autocomplete_invoke($keys, $context) {
  $suggestions = array();

  // Process each enabled engine.
  foreach ($context['engines'] as $engine_id => $engine) {
    if ($engine['enabled'] === TRUE) {
      $callback = 'apachesolr_autocomplete_suggest_' . $engine_id;
      $results = $callback($keys, $context);
      drupal_alter('apachesolr_autocomplete_suggestions', $results, $engine_id);
      if ($results) {
        $results = apachesolr_autocomplete_fix_indexes($results);
        $suggestions = array_merge($suggestions, $results);
      }
    }
  }
  return $suggestions;
}