You are here

public function ViewsMenuLink::loadView in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/views/src/Plugin/Menu/ViewsMenuLink.php \Drupal\views\Plugin\Menu\ViewsMenuLink::loadView()

Initializes the proper view.

Return value

\Drupal\views\ViewExecutable The view executable.

1 call to ViewsMenuLink::loadView()
ViewsMenuLink::updateLink in core/modules/views/src/Plugin/Menu/ViewsMenuLink.php
Updates the definition values for a menu link.

File

core/modules/views/src/Plugin/Menu/ViewsMenuLink.php, line 99

Class

ViewsMenuLink
Defines menu links provided by views.

Namespace

Drupal\views\Plugin\Menu

Code

public function loadView() {
  if (empty($this->view)) {
    $metadata = $this
      ->getMetaData();
    $view_id = $metadata['view_id'];
    $display_id = $metadata['display_id'];
    $view_entity = $this->entityTypeManager
      ->getStorage('view')
      ->load($view_id);
    $view = $this->viewExecutableFactory
      ->get($view_entity);
    $view
      ->setDisplay($display_id);
    $view
      ->initDisplay();
    $this->view = $view;
  }
  return $this->view;
}