You are here

public function ViewExecutable::getUrlInfo in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/views/src/ViewExecutable.php \Drupal\views\ViewExecutable::getUrlInfo()

Gets the Url object associated with the display handler.

Parameters

string $display_id: (optional) The display ID (used only to detail an exception).

Return value

\Drupal\Core\Url The display handlers URL object.

Throws

\InvalidArgumentException Thrown when the display plugin does not have a URL to return.

File

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

Class

ViewExecutable
Represents a view as a whole.

Namespace

Drupal\views

Code

public function getUrlInfo($display_id = '') {
  $this
    ->initDisplay();
  if (!$this->display_handler instanceof DisplayRouterInterface) {
    throw new \InvalidArgumentException("You cannot generate a URL for the display '{$display_id}'");
  }
  return $this->display_handler
    ->getUrlInfo();
}