You are here

public function apachesolr_views_query::init in Apache Solr Views 6

Views init() function

Overrides views_plugin_query::init

File

./apachesolr_views_query.inc, line 98

Class

apachesolr_views_query
Class for handling a view that gets its data not from the database, but from a Solr server.

Code

public function init($base_table, $base_field, $options) {
  $this->base_table = $base_table;
  $this->base_field = $base_field;
  $this->sql_base_table = substr($base_table, 11);
  $this->_solr_service = apachesolr_get_solr();
  module_load_include('inc', 'views', 'plugins/views_plugin_query_default');
  $this->_db_query = new views_plugin_query_default();
  $this->_db_query
    ->init($this->sql_base_table, $base_field, $options);
  $this->id = ++self::$idCount;
  $data = views_fetch_data($base_table);
  foreach ($data as $field_name => $field) {
    if (!empty($field['sort'])) {
      $this->_available_sorts[$field_name] = array(
        'name' => $field['title'],
        'default' => 'asc',
      );
    }
  }
}