Get the required roles from cache if possible.

@return array
499633
private function getRouteRoles()
    {
        $router = $this->router;

        $cache = $this->getConfigCacheFactory()->cache(
            $this->options['cache_dir'].'/tenside_roles.php',
            function (ConfigCacheInterface $cache) use ($router) {
                $routes = $router->getRouteCollection();
                $roles  = [];
                foreach ($routes as $name => $route) {
                    if ($requiredRole = $route->getOption('required_role')) {
                        $roles[$name] = $requiredRole;
                    }
                }

                $cache->write('<?php return ' . var_export($roles, true) . ';', $routes->getResources());
            }
        );

        return require_once $cache->getPath();
    }
804747
public function roleList()
    {
        $body = $this->request(self::URI_AUTH_ROLE_LIST);

        if ($this->pretty && isset($body['roles'])) {
            return $body['roles'];
        }

        return $body;
    }
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));
    }
995971
public function getManageableRolesForPages()
    {
        $roles = $this->em->getRepository('KunstmaanAdminBundle:Role')->findAll();

        if (($token = $this->tokenStorage->getToken()) && ($user = $token->getUser())) {
            if ($user && !$user->isSuperAdmin() && ($superAdminRole = array_keys($roles, 'ROLE_SUPER_ADMIN'))) {
                $superAdminRole = current($superAdminRole);
                unset($roles[$superAdminRole]);
            }
        }

        return $roles;
    }
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,
            ],
        ];
    }
1277999
protected function loadCache(): array
    {
        if ($this->_cache === null)
            $this->_cache = Cacher::getInstance()->get($this->getCacheName());

        return $this->_cache;
    }
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;
  }
48768
public function getRolesAttribute()
    {
        return $this->guild->roles->filter(function ($role) {
            return array_search($role->id, $this->attributes['roles']) !== false;
        });
    }
381048
public function getRolesAttribute()
    {
        $roles = new Collection();

        foreach ($this->guild->roles as $role) {
            if (array_search($role->id, $this->attributes['roles']) !== false) {
                $roles->push($role);
            }
        }

        return $roles;
    }
1105231
public function getUserRoles() {
        $returnValue = $this->internalSession->getUserRoles();
        foreach (array_keys($returnValue) as $key) {
            $role = $returnValue[$key];
            if (!in_array($role, $this->filter)) {
                unset($returnValue[$key]);
            }
        }
        return $returnValue;
    }
151641
public function getRolesWithPermissions(): Collection
    {
        return $this->roleRepository->makeQuery()
            ->with('permissions')
            ->notSuperAdmin()
            ->orderBy('name')
            ->get()
            ->map(function (HCAclRole $role) {
                return [
                    'id' => $role->id,
                    'role' => $role->name,
                    'slug' => $role->slug,
                    'permissions' => $role->permissions->pluck('id')->all(),
                ];
            });
    }
332772
public function findApplicableRoles()
    {
        $widget = $this->widget;
        $array = [];
        foreach ($this->availableRoles as $role) {
            if ($widget->isApplicable($role)) {
                $array[] = $role;
            }
        }
        return $array;
    }
456730
public function getRoles()
	{
		$returnValue = array();
		if ( ! $this->roles) {
			// We use a Depth First Search approach to flatten the Roles Graph.
			foreach ($this->getPropertyValues(GenerisRdf::PROPERTY_USER_ROLES) as $roleUri) {
				$returnValue[] = $roleUri;
				foreach (core_kernel_users_Service::singleton()->getIncludedRoles(new core_kernel_classes_Resource($roleUri)) as $role) {
					$returnValue[] = $role->getUri();
				}
			}
			$returnValue = array_unique($returnValue);
			$this->roles = $returnValue;
		}
		return $this->roles;
	}
542426
public function cachedPermissions()
    {
        $rolePrimaryKey = $this->primaryKey;
        $cacheKey = 'entrust_permissions_for_role_'.$this->$rolePrimaryKey;

        return Cache::tags(Config::get('entrust.permission_role_table'))->remember($cacheKey, Config::get('cache.ttl'), function () {
            return $this->perms()->get();
        });
    }
296961
public function getRoles()
    {
        $roles = array();
        foreach ($this->groups as $group) {
            $roles[] = $group->getAsRole();
        }
        $roles[] = 'ROLE_USER';
        return $roles;
    }
1069773
function roles()
    {
        $groups = $this->attribute( 'groups' );
        $groups[] = $this->attribute( 'contentobject_id' );
        return eZRole::fetchByUser( $groups );
    }
927663
public function getInheritanceList(): array
    {
        $roleList = [$this];
        $role = $this;
        while ($parentRole = $role->getParent()) {
            $roleList[] = $parentRole;
            $role = $parentRole;
        }

        return $roleList;
    }