You are here

protected function DisplayPluginCollection::initializePlugin in Drupal 10

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

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