You are here

public static function CleantalkFuncs::cleantalk_get_user_roles_default in Anti Spam by CleanTalk 8.3

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

File

src/CleantalkFuncs.php, line 772

Class

CleantalkFuncs
Cleantalk class create request

Namespace

Drupal\cleantalk

Code

public static function cleantalk_get_user_roles_default() {
  if (empty(\Drupal::config('cleantalk.settings')
    ->get('cleantalk_roles_exclusions'))) {
    $roles = self::cleantalk_get_user_roles();
    foreach ($roles as $role_id => $role_name) {
      if (strpos('administrator', $role_id) === false) {
        unset($roles[$role_id]);
      }
    }
    return array_keys($roles);
  }
  else {
    $roles = \Drupal::config('cleantalk.settings')
      ->get('cleantalk_roles_exclusions');
    $config_roles = array();
    foreach ((array) $roles as $role => $role_name) {
      $config_roles[$role_name] = $role_name;
    }
    return $config_roles;
  }
}