You are here

protected function UserName::renderLink in Simplenews 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/views/field/UserName.php \Drupal\simplenews\Plugin\views\field\UserName::renderLink()
  2. 3.x src/Plugin/views/field/UserName.php \Drupal\simplenews\Plugin\views\field\UserName::renderLink()
1 call to UserName::renderLink()
UserName::render in src/Plugin/views/field/UserName.php
Renders the field.

File

src/Plugin/views/field/UserName.php, line 21

Class

UserName
Field handler to display username as a link.

Namespace

Drupal\simplenews\Plugin\views\field

Code

protected function renderLink($data, ResultRow $values) {
  $uid = $this
    ->getValue($values);
  if (!empty($uid)) {
    $account = User::load($uid);
    $username = array(
      '#theme' => 'username',
      '#account' => $account,
    );
    return $this
      ->getRenderer()
      ->render($username);
  }
  return [];
}