You are here

function Name::render_link in Views (for Drupal 7) 8.3

Overrides User::render_link

File

lib/Views/user/Plugin/views/field/Name.php, line 76
Definition of Views\user\Plugin\views\field\Name.

Class

Name
Field handler to provide simple renderer that allows using a themed user link.

Namespace

Views\user\Plugin\views\field

Code

function render_link($data, $values) {
  $account = entity_create('user', array());
  $account->uid = $this
    ->get_value($values, 'uid');
  $account->name = $this
    ->get_value($values);
  if (!empty($this->options['link_to_user']) || !empty($this->options['overwrite_anonymous'])) {
    if (!empty($this->options['overwrite_anonymous']) && !$account->uid) {

      // This is an anonymous user, and we're overriting the text.
      return check_plain($this->options['anonymous_text']);
    }
    elseif (!empty($this->options['link_to_user'])) {
      $account->name = $this
        ->get_value($values);
      return theme('username', array(
        'account' => $account,
      ));
    }
  }

  // If we want a formatted username, do that.
  if (!empty($this->options['format_username'])) {
    return user_format_name($account);
  }

  // Otherwise, there's no special handling, so return the data directly.
  return $data;
}