You are here

public function Views::init in Openlayers 7.3

@inheritDoc

Overrides Base::init

File

modules/openlayers_views/src/Plugin/Source/Views/Views.php, line 53
Source: Views.

Class

Views
Class Views.

Namespace

Drupal\openlayers_views\Plugin\Source\Views

Code

public function init() {
  $features = array();
  $source = Openlayers::loadExportable('source', $this
    ->getMachineName());
  if (is_object($source)) {
    $this
      ->setOptions($source->options);
  }
  if ($view = $this
    ->getOption('view', FALSE)) {
    list($views_id, $display_id) = explode(':', $view, 2);
    $view = views_get_view($views_id);
    if ($view && $view
      ->access($display_id)) {
      $view
        ->set_display($display_id);
      if (empty($view->current_display) || !empty($display_id) && $view->current_display != $display_id) {
        if (!$view
          ->set_display($display_id)) {
          return FALSE;
        }
      }
      $view
        ->pre_execute();
      $view
        ->init_style();
      $view
        ->execute();

      // Do not render the map, just return the features.
      $view->style_plugin->options['skipMapRender'] = TRUE;
      $features = array_merge($features, $view->style_plugin
        ->render());
      $view
        ->post_execute();
    }
  }
  $this
    ->setOption('features', $features);
  return parent::init();
}