function Roles::getValueOptions

Same name in other branches
  1. 9 core/modules/user/src/Plugin/views/filter/Roles.php \Drupal\user\Plugin\views\filter\Roles::getValueOptions()
  2. 8.9.x core/modules/user/src/Plugin/views/filter/Roles.php \Drupal\user\Plugin\views\filter\Roles::getValueOptions()
  3. 10 core/modules/user/src/Plugin/views/filter/Roles.php \Drupal\user\Plugin\views\filter\Roles::getValueOptions()

Overrides InOperator::getValueOptions

File

core/modules/user/src/Plugin/views/filter/Roles.php, line 60

Class

Roles
Filter handler for user roles.

Namespace

Drupal\user\Plugin\views\filter

Code

public function getValueOptions() {
    if (!isset($this->valueOptions)) {
        $roles = $this->roleStorage
            ->loadMultiple();
        unset($roles[RoleInterface::ANONYMOUS_ID]);
        unset($roles[RoleInterface::AUTHENTICATED_ID]);
        $this->valueOptions = array_map(fn(RoleInterface $role) => $role->label(), $roles);
    }
    return $this->valueOptions;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.