You are here

public function Eva::getPath in EVA: Entity Views Attachment 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/views/display/Eva.php \Drupal\eva\Plugin\views\display\Eva::getPath()

Returns the base path to use for this display.

This can be overridden for displays that do strange things with the path.

Overrides DisplayPluginBase::getPath

File

src/Plugin/views/display/Eva.php, line 352

Class

Eva
The plugin that handles an EVA display in views.

Namespace

Drupal\eva\Plugin\views\display

Code

public function getPath() {
  if (isset($this->view->current_entity)) {

    /** @var \Drupal\Core\Entity\EntityInterface $current_entity */
    $current_entity = $this->view->current_entity;

    /** @var \Drupal\Core\Url $uri */
    if ($current_entity
      ->hasLinkTemplate('canonical')) {
      $uri = $current_entity
        ->toUrl('canonical');
      if ($uri) {
        $uri
          ->setAbsolute(TRUE);
        return $uri
          ->toUriString();
      }
    }
  }
  return parent::getPath();
}