You are here

protected function DisplayPluginCollection::initializePlugin in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/views/src/DisplayPluginCollection.php \Drupal\views\DisplayPluginCollection::initializePlugin()

Initializes and stores a plugin.

Parameters

string $instance_id: The ID of the plugin instance to initialize.

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'];
  }
}