You are here

function UserUid::title in Views (for Drupal 7) 8.3

Get the title this argument will assign the view, given the argument.

This usually needs to be overridden to provide a proper title.

Overrides ArgumentPluginBase::title

File

lib/Views/comment/Plugin/views/argument/UserUid.php, line 26
Definition of Views\comment\Plugin\views\argument\UserUid.

Class

UserUid
Argument handler to accept a user id to check for nodes that user posted or commented on.

Namespace

Views\comment\Plugin\views\argument

Code

function title() {
  if (!$this->argument) {
    $title = config('user.settings')
      ->get('anonymous');
  }
  else {
    $query = db_select('users', 'u');
    $query
      ->addField('u', 'name');
    $query
      ->condition('u.uid', $this->argument);
    $title = $query
      ->execute()
      ->fetchField();
  }
  if (empty($title)) {
    return t('No user');
  }
  return check_plain($title);
}