function DisplayPluginBase::initDisplay

Same name in other branches
  1. 9 core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::initDisplay()
  2. 8.9.x core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::initDisplay()
  3. 11.x core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::initDisplay()

Overrides DisplayPluginInterface::initDisplay

1 call to DisplayPluginBase::initDisplay()
RestExport::initDisplay in core/modules/rest/src/Plugin/views/display/RestExport.php
Initializes the display plugin.
1 method overrides DisplayPluginBase::initDisplay()
RestExport::initDisplay in core/modules/rest/src/Plugin/views/display/RestExport.php
Initializes the display plugin.

File

core/modules/views/src/Plugin/views/display/DisplayPluginBase.php, line 165

Class

DisplayPluginBase
Base class for views display plugins.

Namespace

Drupal\views\Plugin\views\display

Code

public function initDisplay(ViewExecutable $view, array &$display, ?array &$options = NULL) {
    $this->view = $view;
    // Load extenders as soon as possible.
    $display['display_options'] += [
        'display_extenders' => [],
    ];
    $this->extenders = [];
    if ($extenders = Views::getEnabledDisplayExtenders()) {
        $manager = Views::pluginManager('display_extender');
        $display_extender_options = $display['display_options']['display_extenders'];
        foreach ($extenders as $extender) {
            
            /** @var \Drupal\views\Plugin\views\display_extender\DisplayExtenderPluginBase $plugin */
            if ($plugin = $manager->createInstance($extender)) {
                $extender_options = $display_extender_options[$plugin->getPluginId()] ?? [];
                $plugin->init($this->view, $this, $extender_options);
                $this->extenders[$extender] = $plugin;
            }
        }
    }
    $this->setOptionDefaults($this->options, $this->defineOptions());
    $this->display =& $display;
    // Track changes that the user should know about.
    $changed = FALSE;
    if (!isset($options) && isset($display['display_options'])) {
        $options = $display['display_options'];
    }
    if ($this->isDefaultDisplay() && isset($options['defaults'])) {
        unset($options['defaults']);
    }
    $cid = 'views:unpack_options:' . hash('sha256', serialize([
        $this->options,
        $options,
    ])) . ':' . \Drupal::languageManager()->getCurrentLanguage()
        ->getId();
    if (empty(static::$unpackOptions[$cid])) {
        $cache = \Drupal::cache('data')->get($cid);
        if (!empty($cache->data)) {
            $this->options = $cache->data;
        }
        else {
            $this->unpackOptions($this->options, $options);
            \Drupal::cache('data')->set($cid, $this->options, Cache::PERMANENT, $this->view->storage
                ->getCacheTags());
        }
        static::$unpackOptions[$cid] = $this->options;
    }
    else {
        $this->options = static::$unpackOptions[$cid];
    }
    // Mark the view as changed so the user has a chance to save it.
    if ($changed) {
        $this->view->changed = TRUE;
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.