You are here

public function views_plugin_style_geojson::init in Views GeoJSON 7

If this view is displaying an entity, save the entity type and info.

Overrides views_plugin_style::init

File

views/views_plugin_style_geojson.inc, line 33
Views style plugin to render nodes in the GeoJSON format.

Class

views_plugin_style_geojson
Implementation of views_plugin_style.

Code

public function init(&$view, &$display, $options = NULL) {
  parent::init($view, $display, $options);

  // Pretty-print the JSON.
  module_load_include('inc', 'views_geojson', 'views_geojson.helpers');

  // Search api indexes store the entity metadata in the views data array.
  if (mb_strpos($view->base_table, 'search_api_index_') === 0) {
    $views_data = views_fetch_data();
    if (isset($views_data[$view->base_table]['table']['entity type'])) {
      $this->entity_type = $views_data[$view->base_table]['table']['entity type'];
      $this->entity_info = entity_get_info($this->entity_type);
    }
  }
  else {
    foreach (entity_get_info() as $key => $info) {
      if ($view->base_table === $info['base table']) {
        $this->entity_type = $key;
        $this->entity_info = $info;
        break;
      }
    }
  }
}