function DisplayPluginCollection::initializePlugin

Same name in other branches
  1. 9 core/modules/views/src/DisplayPluginCollection.php \Drupal\views\DisplayPluginCollection::initializePlugin()
  2. 8.9.x core/modules/views/src/DisplayPluginCollection.php \Drupal\views\DisplayPluginCollection::initializePlugin()
  3. 10 core/modules/views/src/DisplayPluginCollection.php \Drupal\views\DisplayPluginCollection::initializePlugin()

Overrides DefaultLazyPluginCollection::initializePlugin

1 call to DisplayPluginCollection::initializePlugin()
DisplayPluginCollection::__construct in core/modules/views/src/DisplayPluginCollection.php
Constructs a DisplayPluginCollection object.

File

core/modules/views/src/DisplayPluginCollection.php, line 71

Class

DisplayPluginCollection
A class which wraps the displays of a view so you can lazy-initialize them.

Namespace

Drupal\views

Code

protected function initializePlugin($display_id) {
    // Retrieve and initialize the new display handler with data.
    $display =& $this->view->storage
        ->getDisplay($display_id);
    try {
        $this->configurations[$display_id] = $display;
        parent::initializePlugin($display_id);
    } catch (PluginException $e) {
        $message = $e->getMessage();
        \Drupal::messenger()->addWarning(t('@message', [
            '@message' => $message,
        ]));
    }
    // If no plugin instance has been created, return NULL.
    if (empty($this->pluginInstances[$display_id])) {
        return NULL;
    }
    $this->pluginInstances[$display_id]
        ->initDisplay($this->view, $display);
    // If this is not the default display handler, let it know which is since
    // it may well use some data from the default.
    if ($display_id != 'default') {
        $this->pluginInstances[$display_id]->default_display = $this->pluginInstances['default'];
    }
}

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