You are here

protected function SearchApiViewsHandlerFilterOptions::get_wrapper in Search API 7

Retrieves a wrapper for this filter's field.

Return value

EntityMetadataWrapper|null A wrapper for the field which this filter uses.

1 call to SearchApiViewsHandlerFilterOptions::get_wrapper()
SearchApiViewsHandlerFilterOptions::get_value_options in contrib/search_api_views/includes/handler_filter_options.inc
Fills the value_options property with all possible options.

File

contrib/search_api_views/includes/handler_filter_options.inc, line 33
Contains the SearchApiViewsHandlerFilterOptions class.

Class

SearchApiViewsHandlerFilterOptions
Views filter handler for fields with a limited set of possible values.

Code

protected function get_wrapper() {
  if ($this->query) {
    $index = $this->query
      ->getIndex();
  }
  elseif (substr($this->view->base_table, 0, 17) == 'search_api_index_') {
    $index = search_api_index_load(substr($this->view->base_table, 17));
  }
  else {
    return NULL;
  }
  $wrapper = $index
    ->entityWrapper(NULL, TRUE);
  $parts = explode(':', $this->real_field);
  foreach ($parts as $i => $part) {
    if (!isset($wrapper->{$part})) {
      return NULL;
    }
    $wrapper = $wrapper->{$part};
    $info = $wrapper
      ->info();
    if ($i < count($parts) - 1) {

      // Unwrap lists.
      $level = search_api_list_nesting_level($info['type']);
      for ($j = 0; $j < $level; ++$j) {
        $wrapper = $wrapper[0];
      }
    }
  }
  return $wrapper;
}