Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ContactLink.php

function ContactLink::renderLink

Overrides LinkBase::renderLink

File

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

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);
    if (!$entity) {
        return '';
    }
    $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;
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal