You are here

public function Domain::getLink in Domain Access 8

Returns a URL object for a domain.

Parameters

bool $current_path: Indicates that the link should point to the path of the current request.

Return value

\Drupal\Core\Url A core URL object.

Overrides DomainInterface::getLink

File

domain/src/Entity/Domain.php, line 469

Class

Domain
Defines the domain entity.

Namespace

Drupal\domain\Entity

Code

public function getLink($current_path = TRUE) {
  $options = [
    'absolute' => TRUE,
    'https' => $this
      ->isHttps(),
  ];
  if ($current_path) {
    $url = Url::fromUri($this
      ->getUrl(), $options);
  }
  else {
    $url = Url::fromUri($this
      ->getPath(), $options);
  }
  return Link::fromTextAndUrl($this
    ->getCanonical(), $url)
    ->toString();
}