You are here

public function BusinessRulesUtil::getUserRolesOptions in Business Rules 8

Same name and namespace in other branches
  1. 2.x src/Util/BusinessRulesUtil.php \Drupal\business_rules\Util\BusinessRulesUtil::getUserRolesOptions()

Get all user roles.

Return value

array Options array.

File

src/Util/BusinessRulesUtil.php, line 580

Class

BusinessRulesUtil
Class BusinessRulesUtil.

Namespace

Drupal\business_rules\Util

Code

public function getUserRolesOptions() {
  $roles = $this->entityTypeManager
    ->getStorage('user_role')
    ->loadMultiple();
  $options = [];

  /**@var  \Drupal\user\Entity\Role $role */
  foreach ($roles as $role) {
    $options[$role
      ->id()] = $role
      ->label();
  }
  asort($options);
  return $options;
}