You are here

RolesRid.php in Views (for Drupal 7) 8.3

Definition of views_handler_argument_users_roles_rid.

File

lib/Views/user/Plugin/views/argument/RolesRid.php
View source
<?php

/**
 * @file
 * Definition of views_handler_argument_users_roles_rid.
 */
namespace Views\user\Plugin\views\argument;

use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugin\views\argument\ManyToOne;

/**
 * Allow role ID(s) as argument.
 *
 * @ingroup views_argument_handlers
 *
 * @Plugin(
 *   id = "users_roles_rid",
 *   module = "user"
 * )
 */
class RolesRid extends ManyToOne {
  function title_query() {
    $titles = array();
    $query = db_select('role', 'r');
    $query
      ->addField('r', 'name');
    $query
      ->condition('r.rid', $this->value);
    $result = $query
      ->execute();
    foreach ($result as $term) {
      $titles[] = check_plain($term->name);
    }
    return $titles;
  }

}

Classes

Namesort descending Description
RolesRid Allow role ID(s) as argument.