protected function UserIntegritySensorPlugin::loadCurrentUsers in Monitoring 8
Gets a list of available users.
Parameters
string[] $role_ids: Roles to filter users.
Return value
\Drupal\user\Entity\User[] Available users.
2 calls to UserIntegritySensorPlugin::loadCurrentUsers()
- UserIntegritySensorPlugin::resultVerbose in src/
Plugin/ monitoring/ SensorPlugin/ UserIntegritySensorPlugin.php - Provide additional info about sensor call.
- UserIntegritySensorPlugin::runSensor in src/
Plugin/ monitoring/ SensorPlugin/ UserIntegritySensorPlugin.php - Runs the sensor, updating $sensor_result.
File
- src/
Plugin/ monitoring/ SensorPlugin/ UserIntegritySensorPlugin.php, line 130 - Contains \Drupal\monitoring\Plugin\monitoring\SensorPlugin\UserIntegritySensorPlugin.
Class
- UserIntegritySensorPlugin
- Monitors user data changes.
Namespace
Drupal\monitoring\Plugin\monitoring\SensorPluginCode
protected function loadCurrentUsers(array $role_ids) {
if (!$role_ids) {
return [];
}
// Loading all users and managing them will kill the system so we limit
// them.
$query = \Drupal::entityQuery('user')
->sort('access', 'DESC')
->range(0, $this->listSize);
// The authenticated role is not persisted and it could have restrict access
// so we load every user.
if (in_array('authenticated', $role_ids)) {
$uids = $query
->condition('uid', '0', '<>')
->execute();
}
else {
// Load all users with the roles.
$uids = $query
->condition('roles', $role_ids, 'IN')
->execute();
}
return User::loadMultiple($uids);
}