You are here

public static function CleantalkFuncs::cleantalk_get_user_roles in Anti Spam by CleanTalk 8.4

Same name and namespace in other branches
  1. 8.3 src/CleantalkFuncs.php \Drupal\cleantalk\CleantalkFuncs::cleantalk_get_user_roles()
  2. 9.1.x src/CleantalkFuncs.php \Drupal\cleantalk\CleantalkFuncs::cleantalk_get_user_roles()
2 calls to CleantalkFuncs::cleantalk_get_user_roles()
CleantalkFuncs::cleantalk_get_user_roles_default in src/CleantalkFuncs.php
CleantalkSettingsForm::buildForm in src/Form/CleantalkSettingsForm.php
Form constructor.

File

src/CleantalkFuncs.php, line 707

Class

CleantalkFuncs
Cleantalk class create request

Namespace

Drupal\cleantalk

Code

public static function cleantalk_get_user_roles() {
  $roles = \Drupal\user\Entity\Role::loadMultiple();
  $roles_arr = array();
  foreach ($roles as $role) {
    $roles_arr[$role
      ->get('id')] = $role
      ->get('label');
  }
  asort($roles_arr);
  return $roles_arr;
}