You are here

function search_api_autocomplete_suggester_info in Search API Autocomplete 7

Retrieves the definitions of all suggester plugins, or a specific one.

Parameters

string|null $suggester_id: (optional) The ID of the suggester plugin whose definition should be retrieved. Or NULL to return all known definitions.

Return value

array|null If $suggester_id was given, either the definition of the given suggester plugin, or NULL if it isn't known. Otherwise, an associative array of all known suggester plugin definitions, keyed by ID.

2 calls to search_api_autocomplete_suggester_info()
search_api_autocomplete_suggesters_for_index in ./search_api_autocomplete.module
Retrieves all suggester plugin definitions that support the given index.
search_api_autocomplete_suggester_load in ./search_api_autocomplete.module
Loads the specified suggester plugin.

File

./search_api_autocomplete.module, line 240
Adds autocomplete capabilities for Search API searches.

Code

function search_api_autocomplete_suggester_info($suggester_id = NULL) {
  $suggesters =& drupal_static(__FUNCTION__);
  if (!isset($suggesters)) {
    $suggesters = module_invoke_all('search_api_autocomplete_suggester_info');
    drupal_alter('search_api_autocomplete_suggester_info', $suggesters);
    foreach ($suggesters as $i => $definition) {
      if (empty($definition['class']) || !class_exists($definition['class']) || !in_array('SearchApiAutocompleteSuggesterInterface', class_implements($definition['class']))) {
        $variables['@suggester_id'] = $i;
        watchdog('search_api_autocomplete', 'Autocomplete suggester plugin with ID @suggester_id does not specify a valid plugin class.', $variables, WATCHDOG_ERROR);
        unset($suggesters[$i]);
      }
    }
  }
  if (!isset($suggester_id)) {
    return $suggesters;
  }
  return isset($suggesters[$suggester_id]) ? $suggesters[$suggester_id] : NULL;
}