function ViewExecutable::attachDisplays

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

Runs attachment displays for the view.

1 call to ViewExecutable::attachDisplays()
ViewExecutable::build in core/modules/views/src/ViewExecutable.php
Builds the query for the view.

File

core/modules/views/src/ViewExecutable.php, line 1774

Class

ViewExecutable
Represents a view as a whole.

Namespace

Drupal\views

Code

public function attachDisplays() {
  if (!empty($this->is_attachment)) {
    return;
  }
  if (!$this->display_handler
    ->acceptAttachments()) {
    return;
  }
  $this->is_attachment = TRUE;
  // Find out which other displays attach to the current one.
  foreach ($this->display_handler
    ->getAttachedDisplays() as $id) {
    $display_handler = $this->displayHandlers
      ->get($id);
    // Only attach enabled attachments that the user has access to.
    if ($display_handler->isEnabled() && $display_handler->access()) {
      $cloned_view = Views::executableFactory()->get($this->storage);
      $display_handler->attachTo($cloned_view, $this->current_display, $this->element);
    }
  }
  $this->is_attachment = FALSE;
}

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