You are here

function sarnia_index_get_options in Sarnia 7

Same name in this branch
  1. 7 sarnia.api.php \sarnia_index_get_options()
  2. 7 sarnia.module \sarnia_index_get_options()

Get a list of Solr fields for a particular Search API index.

Parameters

string $index_machine_name: The machine name of a Search API index.

string $filter_method: May be a string or NULL. If a string, the method of that name will be called on an instance of the SolrField class for each possible field. Especially useful are the values 'isPossibleKey', 'isSortable', and 'isIndexed'.

Return value

array An array of Solr fields, where the keys are Solr field names and the values are field labels. This array is suitable for use as a Form API #options property.

3 calls to sarnia_index_get_options()
SarniaViewsHandlerSort::options_form in handlers/handler_sort.inc
Basic options for all sort criteria
sarnia_index_get_field_options in ./sarnia.module
Get and cache a list of retrievable fields for a particular Search API index.
sarnia_index_get_filter_options in ./sarnia.module
Get and cache a list of filterable fields for a particular Search API index.

File

./sarnia.module, line 762

Code

function sarnia_index_get_options($index_machine_name, $filter_method = NULL) {
  $options = array();
  if ($index = search_api_index_load($index_machine_name)) {
    foreach ($index
      ->server()
      ->{$filter_method}() as $name => $field) {

      //@TODO Allow admins to provide labels for solr fields.
      $options[$field
        ->getName()] = $name;
    }
    asort($options);
  }
  return $options;
}