Get all available and assigned roles, permission and routes

@return array
480068
public function getItems(): array
    {
        $available = [];
        $assigned = [];

        if ($this->type == Item::TYPE_ROLE) {
            foreach (array_keys($this->manager->getRoles()) as $name) {
                $available[$name] = 'role';
            }
        }
        foreach (array_keys($this->manager->getPermissions()) as $name) {
            $available[$name] = $name[0] == '/' ? 'route' : 'permission';
        }

        foreach ($this->manager->getChildren($this->_item->name) as $item) {
            $assigned[$item->name] = $item->type == 1 ? 'role' : ($item->name[0] == '/' ? 'route' : 'permission');
            unset($available[$item->name]);
        }

        unset($available[$this->name]);

        return [
            'available' => $available,
            'assigned' => $assigned,
        ];
    }
659465
public function getUserRolePermissions()
  {
    $roles = Role::select('id', 'name', 'label')->get();
    $permissions = Permission::select('id', 'name', 'label')->get();
    return \View::make('admin.permissions.role-assign-permissions', [
      'roles'              =>  $roles,
      'permissions'        =>  $permissions,
      'title'              => 'assign',
    ]);
  }
467194
public function currentRoleCachedPermissions()
    {
        $cacheKey = 'laratrust_permissions_for_role_' . $this->role->getKey();

        if (!Config::get('laratrust.cache.enabled')) {
            return $this->role->permissions()->get();
        }

        return Cache::remember($cacheKey, Config::get('laratrust.cache.expiration_time', 60), function () {
            return $this->role->permissions()->get()->toArray();
        });
    }
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);
    }
927508
protected function getFilteredPermissions()
    {
        $permissions = BackendAuth::listTabbedPermissions();

        if ($this->user->isSuperUser()) {
            return $permissions;
        }

        foreach ($permissions as $tab => $permissionsArray) {
            foreach ($permissionsArray as $index => $permission) {
                if (!$this->user->hasAccess($permission->code)) {
                    unset($permissionsArray[$index]);
                }
            }

            if (empty($permissionsArray)) {
                unset($permissions[$tab]);
            }
            else {
                $permissions[$tab] = $permissionsArray;
            }
        }

        return $permissions;
    }
981413
protected function getRolesWithPermission() {
    $roles_with_perm = [];

    /* @var \Drupal\user\RoleInterface[] $roles */
    $roles = Role::loadMultiple();

    // Check for each role which one has permission to "view inappropriate
    // reports".
    foreach ($roles as $role) {
      if ($role->hasPermission('view inappropriate reports')) {
        $roles_with_perm[] = $role->id();
      }
    }

    return $roles_with_perm;
  }
1149097
public function getPermissions(): array
    {
        $userID = $this->getID();
        if ($userID === null) {
            return [];
        }
        $data = Internal\Data::getValue('bearcms/users/user/' . md5($userID) . '.json');
        if ($data !== null) {
            $user = json_decode($data, true);
            return isset($user['permissions']) ? $user['permissions'] : [];
        }
        return [];
    }
290909
public function getAllAvailableRoles ()
    {
        return array_filter(
            $this->roleCollection,
            function (BaseRole $role)
            {
                if ($role instanceof Role)
                {
                    return !$role->isHidden();
                }

                //remove all BaseRoles
                return false;
            }
        );
    }
401198
public function getAllowedRoles()
    {
        $returnValue = array();

        $role = new core_kernel_classes_Resource(GenerisRdf::INSTANCE_ROLE_GENERIS);
        $returnValue = array($role->getUri() => $role);

        return (array) $returnValue;
    }
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,
            ],
        ];
    }
758162
public function loadRoles()
    {
        $data = $this->roleGateway->loadRoles();

        $roles = $this->mapper->mapRoles($data);
        foreach ($roles as $role) {
            foreach ($role->policies as $policy) {
                $this->limitationConverter->toSPI($policy);
            }
        }

        return $roles;
    }
393744
protected function findAvailableRoutes()
    {
        $routes = [];
        $rules = Director::config()->get('rules');

        foreach ($rules as $pattern => $controllerInfo) {
            $routeClass = (is_string($controllerInfo)) ? $controllerInfo : $controllerInfo['Controller'];

            try {
                $routeController = Injector::inst()->get($routeClass);
                if ($routeController instanceof Controller) {
                    $routes[] = $pattern;
                }
            } catch (InjectorNotFoundException $ex) {
            }

        }
        return $routes;
    }
1038069
protected function getRoles() {
        if (!$this->_roles) {
            $this->_roles = new RoleList($this->version, $this->solution['sid']);
        }

        return $this->_roles;
    }
1370082
protected function getAllPermissions() {
    $permissions = &drupal_static(__FUNCTION__);

    if (!isset($permissions)) {
      $permissions = \Drupal::service('user.permissions')->getPermissions();
    }

    return $permissions;
  }
438395
public function allPermissions()
    {
        $roles = $this->roles()->with('permissions')->get();

        $roles = $roles->flatMap(function ($role) {
            return $role->permissions;
        });

        return $this->permissions()->get()->merge($roles)->unique('name');
    }
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);
    }
100074
protected function getRoleIds()
    {
        list($models, $names) = Helpers::partition($this->roles, function ($role) {
            return $role instanceof Model;
        });

        $ids = $models->map(function ($model) {
            return $model->getKey();
        });

        if ($names->count()) {
            $ids = $ids->merge($this->getRoleIdsFromNames($names->all()));
        }

        return $ids->all();
    }