protected function UserIntegritySensorPlugin::getRestrictedRoles in Monitoring 8
Gets a list of restricted roles.
Return value
string[] Restricted roles.
2 calls to UserIntegritySensorPlugin::getRestrictedRoles()
- 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 194 - Contains \Drupal\monitoring\Plugin\monitoring\SensorPlugin\UserIntegritySensorPlugin.
Class
- UserIntegritySensorPlugin
- Monitors user data changes.
Namespace
Drupal\monitoring\Plugin\monitoring\SensorPluginCode
protected function getRestrictedRoles() {
/** @var \Drupal\user\PermissionHandlerInterface $permission_handler */
$permission_handler = \Drupal::service('user.permissions');
$available_permissions = $permission_handler
->getPermissions();
$this->restrictedPermissions = array();
foreach ($available_permissions as $key => $value) {
if (!empty($value['restrict access'])) {
$this->restrictedPermissions[] = $key;
}
}
$avaliable_roles = Role::loadMultiple();
$restricted_roles = array();
foreach ($avaliable_roles as $role) {
$permissions = $role
->getPermissions();
if ($role
->isAdmin() || array_intersect($permissions, $this->restrictedPermissions)) {
$restricted_roles[] = $role
->id();
}
}
return $restricted_roles;
}