You are here

public function SearchApiDatasource::getValueOptions in Search API 8

Child classes should be used to override this function and set the 'value options', unless 'options callback' is defined as a valid function or static public method to generate these values.

This can use a guard to be used to reduce database hits as much as possible.

Return value

array|null The stored values from $this->valueOptions.

Overrides SearchApiOptions::getValueOptions

File

src/Plugin/views/filter/SearchApiDatasource.php, line 17

Class

SearchApiDatasource
Provides filtering on the datasource.

Namespace

Drupal\search_api\Plugin\views\filter

Code

public function getValueOptions() {
  if (isset($this->valueOptions)) {
    return $this->valueOptions;
  }
  $this->valueOptions = [];
  $index = $this
    ->getIndex();
  if ($index) {
    foreach ($index
      ->getDatasources() as $datasource_id => $datasource) {
      $this->valueOptions[$datasource_id] = $datasource
        ->label();
    }
  }
  return $this->valueOptions;
}