Find applicable roles.

@return string[]
332772
public function findApplicableRoles()
    {
        $widget = $this->widget;
        $array = [];
        foreach ($this->availableRoles as $role) {
            if ($widget->isApplicable($role)) {
                $array[] = $role;
            }
        }
        return $array;
    }
1147321
public function getRoles()
    {
        return \is_string($value = $this->getContentValue('roles', null))
            ? array_filter(explode(',', (string) $value))
            : null;
    }
1374370
public function getRoles()
    {
        $user       = $this;
        $comparator = function ($level) use ($user) {
            return $user->hasAccessLevel($level);
        };

        // Fallback for PHP < 5.6 which do not support ARRAY_FILTER_USE_KEY.
        if (version_compare(PHP_VERSION, '5.6', '<')) {
            $filtered = array_flip(array_filter(array_keys(self::$roleMap), $comparator));
            return array_values(array_intersect_key(self::$roleMap, $filtered));
        }

        return array_values(array_filter(self::$roleMap, $comparator, ARRAY_FILTER_USE_KEY));
    }
841243
public function getFilters()
    {
        $roles = user_roles(true);
        unset($roles[DRUPAL_AUTHENTICATED_RID]);

        return [
            (new Filter('status', $this->t("Active")))->setChoicesMap(
                [
                    0 => $this->t("No"),
                    1 => $this->t("Yes"),
                ]
            ),
            (new Filter('role', $this->t("Role")))->setChoicesMap($roles),
            (new Filter('name', $this->t("Name"))),
        ];
    }
738444
public function getRolesIdList() {

		$roles		= $this->roleMappingList;
		$rolesList	= array();

		foreach ( $roles as $role ) {

			array_push( $rolesList, $role->roleId );
		}

		return $rolesList;
	}
74698
public function roles() {
		$user = $this->user();
		if (!$user) {
			return [];
		}

		$roles = $this->_getUserRoles($user);

		return $roles;
	}
1153775
protected function _getRoleNames()
    {
        $names = [];
        if (!$this->has('roles')) {
            return $names;
        }
        foreach ($this->roles as $k => $role) {
            $names[] = $role->name;
        }

        return $names;
    }
448474
public function getRolesWithPermissions()
    {
        $roles = Roles::with('permissions')
            ->notSuperAdmin()
            ->orderBy('name')
            ->get()->map(function ($role) {
                return [
                    'id'          => $role->id,
                    'role'        => $role->name,
                    'slug'        => $role->slug,
                    'permissions' => $role->permissions->pluck('id')->all(),
                ];
            });

        return json_encode($roles);
    }
1157381
public function getRoles() {
		if ( $this->cacheEnabled() ) {
			if ( is_null( $this->getCachedRoles() ) ) {
				Cache::remember( 'roles.user_' . $this->id, config( 'roles.cache.expiry' ), function () {
					return $this->roles()->get();
				} );
			}

			return $this->getCachedRoles();
		} else {
			return $this->roles()->get();
		}
	}
896198
private function getExpandedRoles(array $roleScopes)
    {
        $expandedRoles = array();
        foreach ($roleScopes as $roleScope) {
            if (!array_key_exists($roleScope->getRole(), $expandedRoles)) {
                $expandedRoles[$roleScope->getRole()] = 
                      array_map(
                            function(RoleInterface $role) {
                          
                                return $role->getRole();
                            },
                            $this->get('security.role_hierarchy')
                                ->getReachableRoles(
                                      array(new Role($roleScope->getRole()))
                                    )
                        );
            }
        }
        return $expandedRoles;
    }
439778
public function getExplicitRoles()
    {
        $manager = \FelixOnline\Core\BaseManager::build('FelixOnline\Core\UserRole', 'user_roles', 'id');
        $manager->filter('user = "%s"', array($this->getUser()));

        $values = $manager->values();
        if (!$values) {
            return null;
        }

        $roles = array();
        foreach ($values as $value) {
            $roles[] = $value->getRole();
        }

        return $roles;
    }
1192119
protected function _getAvailableRoles() {
		if ($this->_roles !== null) {
			return $this->_roles;
		}

		$roles = Configure::read($this->getConfig('rolesTable'));
		if (is_array($roles)) {
			if ($this->getConfig('superAdminRole')) {
				$key = $this->getConfig('superAdmin') ?: 'superadmin';
				$roles[$key] = $this->getConfig('superAdminRole');
			}
			return $roles;
		}

		$rolesTable = TableRegistry::get($this->getConfig('rolesTable'));
		$result = $rolesTable->find()->formatResults(function (ResultSetInterface $results) {
			return $results->combine($this->getConfig('aliasColumn'), 'id');
		});
		$roles = $result->toArray();

		if ($this->getConfig('superAdminRole')) {
			$key = $this->getConfig('superAdmin') ?: 'superadmin';
			$roles[$key] = $this->getConfig('superAdminRole');
		}

		if (count($roles) < 1) {
			throw new Exception('Invalid TinyAuth role setup (roles table `' . $this->getConfig('rolesTable') . '` has no roles)');
		}

		$this->_roles = $roles;

		return $roles;
	}
1251035
public static function getRoles()
    {
        return [
            self::ROLE_MEMBER => Yii::t('podium/view', 'Member'),
            self::ROLE_MODERATOR => Yii::t('podium/view', 'Moderator'),
            self::ROLE_ADMIN => Yii::t('podium/view', 'Admin'),
        ];
    }
573156
protected static function getRoleConfigs() {
    if (self::$roleConfig == null) {
      // load role config if existing
      $config = ObjectFactory::getInstance('configuration');
      if (($roleConfig = $config->getSection('roleconfig')) !== false) {
        self::$roleConfig = $roleConfig;
      }
    }
    return self::$roleConfig;
  }
607575
public function roleListAction()
    {
        $roles = $this->roleManager->getAllPlatformRoles();
        $counts = [];

        foreach ($roles as $role) {
            $counts[$role->getName()] = $this->roleManager->countUsersByRoleIncludingGroup($role);
        }

        return array('roles' => $roles, 'counts' => $counts);
    }
1175836
protected function getAclRoles()
    {
        $aclRoles = [];
        $roleHierarchy = $this->container->getParameter('security.role_hierarchy.roles');
        $pool = $this->container->get('sonata.admin.pool');

        foreach ($pool->getAdminServiceIds() as $id) {
            try {
                $admin = $pool->getInstance($id);
            } catch (\Exception $e) {
                continue;
            }

            $baseRole = $admin->getSecurityHandler()->getBaseRole($admin);
            foreach ($admin->getSecurityInformation() as $role => $permissions) {
                $role = sprintf($baseRole, $role);
                $aclRoles[] = $role;
            }
        }

        foreach ($roleHierarchy as $name => $roles) {
            $aclRoles[] = $name;
            $aclRoles = array_merge($aclRoles, $roles);
        }

        $aclRoles = array_unique($aclRoles);

        return \is_array($aclRoles) ? new \ArrayIterator($aclRoles) : $aclRoles;
    }
616806
private function getRolesPermissions()
    {
        return [
            [
                'name'        => 'Roles - List all roles',
                'description' => 'Allow to list all roles.',
                'slug'        => RolesPolicy::PERMISSION_LIST,
            ],
            [
                'name'        => 'Roles - View a role',
                'description' => 'Allow to view the role\'s details.',
                'slug'        => RolesPolicy::PERMISSION_SHOW,
            ],
            [
                'name'        => 'Roles - Add/Create a role',
                'description' => 'Allow to create a new role.',
                'slug'        => RolesPolicy::PERMISSION_CREATE,
            ],
            [
                'name'        => 'Roles - Edit/Update a role',
                'description' => 'Allow to update a role.',
                'slug'        => RolesPolicy::PERMISSION_UPDATE,
            ],
            [
                'name'        => 'Roles - Delete a role',
                'description' => 'Allow to delete a role.',
                'slug'        => RolesPolicy::PERMISSION_DELETE,
            ],
        ];
    }