You are here

public function NodeTypeCountController::userCountByRole in Node Type count 8

Count User Role.

1 call to NodeTypeCountController::userCountByRole()
NodeTypeCountController::userRoleCount in src/Controller/NodeTypeCountController.php
This code (noted in the callback above) creates the.

File

src/Controller/NodeTypeCountController.php, line 134
Contains \Drupal\node_type_count\Controller\NodeTypeCountController.

Class

NodeTypeCountController
Controller routines for page example routes.

Namespace

Drupal\node_type_count\Controller

Code

public function userCountByRole($role_type_machine_name) {
  $query = db_select('user__roles', 'ur')
    ->fields('ur', array(
    'entity_id',
  ))
    ->condition('roles_target_id', $role_type_machine_name);
  $results = $query
    ->countQuery()
    ->execute()
    ->fetchField();
  return $results;
}