function ViewsMenuLink::loadView

Same name in other branches
  1. 9 core/modules/views/src/Plugin/Menu/ViewsMenuLink.php \Drupal\views\Plugin\Menu\ViewsMenuLink::loadView()
  2. 8.9.x core/modules/views/src/Plugin/Menu/ViewsMenuLink.php \Drupal\views\Plugin\Menu\ViewsMenuLink::loadView()
  3. 10 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 92

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

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