You are here

protected function ContactLink::renderLink in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/contact/src/Plugin/views/field/ContactLink.php \Drupal\contact\Plugin\views\field\ContactLink::renderLink()

Prepares the link to view a entity.

Parameters

\Drupal\views\ResultRow $row: A view result row.

Return value

string Returns a string for the link text.

Overrides LinkBase::renderLink

File

core/modules/contact/src/Plugin/views/field/ContactLink.php, line 39

Class

ContactLink
Defines a field that links to the user contact page, if access is permitted.

Namespace

Drupal\contact\Plugin\views\field

Code

protected function renderLink(ResultRow $row) {
  $entity = $this
    ->getEntity($row);
  $this->options['alter']['make_link'] = TRUE;
  $this->options['alter']['url'] = $this
    ->getUrlInfo($row);
  $title = $this
    ->t('Contact %user', [
    '%user' => $entity
      ->label(),
  ]);
  $this->options['alter']['attributes'] = [
    'title' => $title,
  ];
  if (!empty($this->options['text'])) {
    return $this->options['text'];
  }
  else {
    return $title;
  }
}