You are here

public function DisplayPluginBase::init in Views (for Drupal 7) 8.3

1 call to DisplayPluginBase::init()
Feed::init in lib/Drupal/views/Plugin/views/display/Feed.php
1 method overrides DisplayPluginBase::init()
Feed::init in lib/Drupal/views/Plugin/views/display/Feed.php

File

lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php, line 92
Definition of Drupal\views\Plugin\views\display\DisplayPluginBase.

Class

DisplayPluginBase
The default display plugin handler. Display plugins handle options and basic mechanisms for different output methods.

Namespace

Drupal\views\Plugin\views\display

Code

public function init(ViewExecutable $view, &$display, $options = NULL) {
  $this
    ->setOptionDefaults($this->options, $this
    ->defineOptions());
  $this->view =& $view;
  $this->display =& $display;

  // Load extenders as soon as possible.
  $this->extender = array();
  $extenders = views_get_enabled_display_extenders();
  if (!empty($extenders)) {
    foreach ($extenders as $extender) {
      $plugin = views_get_plugin('display_extender', $extender);
      if ($plugin) {
        $plugin
          ->init($this->view, $this);
        $this->extender[$extender] = $plugin;
      }
    }
  }

  // Track changes that the user should know about.
  $changed = FALSE;

  // Make some modifications:
  if (!isset($options) && isset($display['display_options'])) {
    $options = $display['display_options'];
  }
  if ($this
    ->isDefaultDisplay() && isset($options['defaults'])) {
    unset($options['defaults']);
  }
  views_include('cache');

  // Cache for unpackOptions, but not if we are in the ui.
  static $unpack_options = array();
  if (empty($view->editing)) {
    $cid = 'unpackOptions:' . md5(serialize(array(
      $this->options,
      $options,
    )));
    if (empty($unpack_options[$cid])) {
      $cache = views_cache_get($cid, TRUE);
      if (!empty($cache->data)) {
        $this->options = $cache->data;
      }
      else {
        $this
          ->unpackOptions($this->options, $options);
        views_cache_set($cid, $this->options, TRUE);
      }
      $unpack_options[$cid] = $this->options;
    }
    else {
      $this->options = $unpack_options[$cid];
    }
  }
  else {
    $this
      ->unpackOptions($this->options, $options);
  }

  // Convert the field_language and field_language_add_to_query settings.
  $field_language = $this
    ->getOption('field_language');
  $field_language_add_to_query = $this
    ->getOption('field_language_add_to_query');
  if (isset($field_langcode)) {
    $this
      ->setOption('field_langcode', $field_language);
    $this
      ->setOption('field_langcode_add_to_query', $field_language_add_to_query);
    $changed = TRUE;
  }

  // Mark the view as changed so the user has a chance to save it.
  if ($changed) {
    $this->view->changed = TRUE;
  }
}