public function DisplayPluginBase::initDisplay

2 calls to DisplayPluginBase::initDisplay()
Feed::initDisplay in drupal/core/modules/views/lib/Drupal/views/Plugin/views/display/Feed.php
Overrides \Drupal\views\Plugin\views\display\DisplayPluginBase::initDisplay().
RestExport::initDisplay in drupal/core/modules/rest/lib/Drupal/rest/Plugin/views/display/RestExport.php
2 methods override DisplayPluginBase::initDisplay()
Feed::initDisplay in drupal/core/modules/views/lib/Drupal/views/Plugin/views/display/Feed.php
Overrides \Drupal\views\Plugin\views\display\DisplayPluginBase::initDisplay().
RestExport::initDisplay in drupal/core/modules/rest/lib/Drupal/rest/Plugin/views/display/RestExport.php

File

drupal/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php, line 102
Contains 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 initDisplay(ViewExecutable $view, array &$display, array &$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)) {
    $manager = Views::pluginManager('display_extender');
    foreach ($extenders as $extender) {
      $plugin = $manager
        ->createInstance($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']);
  }

  // Cache for unpackOptions, but not if we are in the ui.
  static $unpack_options = array();
  if (empty($view->editing)) {
    $cid = 'unpackOptions:' . hash('sha256', 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;
  }
}