You are here

protected function SearchApiViewsFacetsBlockDisplay::getFieldOptions in Search API 7

2 calls to SearchApiViewsFacetsBlockDisplay::getFieldOptions()
SearchApiViewsFacetsBlockDisplay::options_form in contrib/search_api_views/includes/display_facet_block.inc
Provide the default form for setting options.
SearchApiViewsFacetsBlockDisplay::options_summary in contrib/search_api_views/includes/display_facet_block.inc
Provide the summary for page options in the views UI.

File

contrib/search_api_views/includes/display_facet_block.inc, line 117
Display plugin for displaying the search facets in a block.

Class

SearchApiViewsFacetsBlockDisplay
Plugin class for displaying search facets in a block.

Code

protected function getFieldOptions() {
  if (!isset($this->field_options)) {
    $index_id = substr($this->view->base_table, 17);
    if (!($index_id && ($index = search_api_index_load($index_id)))) {
      $table = views_fetch_data($this->view->base_table);
      $table = empty($table['table']['base']['title']) ? $this->view->base_table : $table['table']['base']['title'];
      throw new SearchApiException(t('The "Facets block" display cannot be used with a view for @basetable. ' . 'Please only use this display with base tables representing search indexes.', array(
        '@basetable' => $table,
      )));
    }
    $this->field_options = array();
    if (!empty($index->options['fields'])) {
      foreach ($index
        ->getFields() as $key => $field) {
        $this->field_options[$key] = $field['name'];
      }
    }
  }
  return $this->field_options;
}