You are here

public function DisplayPluginBase::getRoutedDisplay in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::getRoutedDisplay()

Points to the display which can be linked by this display.

If the display has route information, the display itself is returned. Otherwise, the configured linked display is returned. For example, if a block display links to a page display, the page display will be returned in both cases.

Return value

\Drupal\views\Plugin\views\display\DisplayRouterInterface|null

Overrides DisplayPluginInterface::getRoutedDisplay

1 call to DisplayPluginBase::getRoutedDisplay()
DisplayPluginBase::validate in core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
Validate that the plugin is correct and can be saved.

File

core/modules/views/src/Plugin/views/display/DisplayPluginBase.php, line 743

Class

DisplayPluginBase
Base class for views display plugins.

Namespace

Drupal\views\Plugin\views\display

Code

public function getRoutedDisplay() {

  // If this display has a route, return this display.
  if ($this instanceof DisplayRouterInterface) {
    return $this;
  }

  // If the display does not have a route (e.g. a block display), get the
  // route for the linked display.
  $display_id = $this
    ->getLinkDisplay();
  if ($display_id && $this->view->displayHandlers
    ->has($display_id) && is_object($this->view->displayHandlers
    ->get($display_id))) {
    return $this->view->displayHandlers
      ->get($display_id)
      ->getRoutedDisplay();
  }

  // No routed display exists, so return NULL
  return NULL;
}