------------------------------------------------------ roles
764167
@Process(actionType = ModifyStandardRole.class)
    public void modifyStandardRole(final ModifyStandardRole action, final Channel channel) {
        Role role = action.getRole();
        new Async<FunctionContext>().waterfall(new FunctionContext(), new ReloadOutcome(channel),
                new AccessControlFunctions.CheckAssignment(dispatcher, role),
                new AccessControlFunctions.AddAssignment(dispatcher, role, status -> status == 404),
                new AccessControlFunctions.ModifyIncludeAll(dispatcher, role));
    }
905584
public void addRole(Role role) {
        apiRoles.add(role);
        roles.add(role.getName());
        for (org.seedstack.seed.security.Permission permission : role.getPermissions()) {
            if (!role.getScopes().isEmpty()) {
                for (Scope scope : role.getScopes()) {
                    ScopePermission sp = new ScopePermission(permission.getPermission(), scope);
                    scopePermissions.add(sp);
                }
            } else {
                stringPermissions.add(permission.getPermission());
            }
        }
    }
44682
private function compileUserRoles()
    {
        if ($this->userRoles !== null) {
            return;
        }

        if (!$this->user) {
            $this->userRoles = [];

            return;
        }

        $roleList = [];
        $roleExpansion = [];

        /** @var Role $role */
        foreach ($this->roleProvider->getAllRoles() as $role) {
            $roleList[$role->getId()] = $role;
        }

        /** @var Role $userRole */
        $userRoles = $this->user->getRoles();
        if ($userRoles) {
            foreach ($userRoles as $userRole) {
                $roleExpansion[] = $userRole->getName();

                $parentRole = $userRole->getParent();
                while ($parentRole) {
                    $roleExpansion[] = $parentRole->getName();
                    $parentRole = $parentRole->getParent();
                }
            }
        }
        $this->userRoles = array_unique($roleExpansion);
    }
1301052
def roles(*roles) 
      self.valid_roles = Array[*roles].flatten.map { |r| r.to_sym }
    end
1235547
protected function _addRoles($roles)
    {
        foreach ($roles as $name => $parent) {
            if (!$this->hasRole($name)) {
                if (empty($parent)) {
                    $parent = array();
                } else {
                    $parent = explode(',', $parent);
                }

                $this->addRole(new Role($name), $parent);
            }
        }

        return $this;
    }
151279
public void map(final Group group, final Role role)
    {
        this.getRoleMappings().add(new RoleMapping(group, role));
    }
364998
def role?(role_sym)
      role_sym = [role_sym] unless role_sym.is_a?(Array)

      roles.map { |r| r.name.underscore.to_sym }.any? { |user_role| role_sym.include?(user_role) }
    end
1300986
public void buildRoleLinks(RoleManager rm) {
        if (model.containsKey("g")) {
            for (Assertion ast : model.get("g").values()) {
                ast.buildRoleLinks(rm);
            }
        }
    }
67131
public function attachRole($role)
    {
        if (! $this->hasRole($role->name)) {
            $this->roles()->attach($role);
        }
    }
1289678
public function addRole($role, array $resources = [])
    {
        if ($role instanceof RoleInterface) {
            $this->roles[$role->getName()] = $role;
        } else {
            $role = new Role($role, $resources);
            $this->roles[$role->getName()] = $role;
        }
    }
1334192
private Set<Role> getOtherRolesArg(Object[] arguments) {
        if (arguments.length <= NEW_ROLES_INDEX) {
            log.error("Illegal number of args: " + arguments.length);
        }

        Set<Role> roles = new HashSet<Role>();
        Object[] rolesArray = (Object[]) arguments[NEW_ROLES_INDEX];
        if (null != rolesArray && rolesArray.length > 0) {
            for (Object role : rolesArray) {
                roles.add((Role) role);
            }
        }

        return roles;
    }
998402
protected function initSURole() : void
    {
        $this->stdout("Init SU role \n",  Console::FG_YELLOW);
        $this->authManager->removeAll();
        $su = $this->authManager->createRole(Rbac::R_SU);
        $su->description = 'Super User';
        $this->authManager->add($su);
    }
320790
protected function addUserRole()
    {
        $this->controlAccess('user_role_add');

        if ($this->role->add($this->getSubmitted())) {
            $this->redirect('admin/user/role', $this->text('Role has been added'), 'success');
        }

        $this->redirect('', $this->text('Role has not been added'), 'warning');
    }
808727
protected function job(): void
    {
        while (true) {

            $roles = $this->retrieve([
                'corporation_id' => $this->getCorporationId(),
            ]);

            if ($roles->isCachedLoad()) return;

            collect($roles)->each(function ($role) {

                collect($role->old_roles)->each(function ($role_id) use ($role) {

                    CorporationRoleHistory::firstOrNew([
                        'corporation_id' => $this->getCorporationId(),
                        'character_id'   => $role->character_id,
                        'changed_at'     => carbon($role->changed_at),
                        'role_type'      => $role->role_type,
                        'state'          => 'old',
                        'role'           => $role_id,
                    ])->fill([
                        'issuer_id' => $role->issuer_id,
                    ])->save();

                });

                collect($role->new_roles)->each(function ($role_id) use ($role) {

                    CorporationRoleHistory::firstOrNew([
                        'corporation_id' => $this->getCorporationId(),
                        'character_id'   => $role->character_id,
                        'changed_at'     => carbon($role->changed_at),
                        'role_type'      => $role->role_type,
                        'state'          => 'new',
                        'role'           => $role_id,
                    ])->fill([
                        'issuer_id' => $role->issuer_id,
                    ])->save();

                });

            });

            if (! $this->nextPage($roles->pages))
                break;
        }
    }
984913
public void setRole(java.lang.String role) {
        getStateHelper().put(PropertyKeys.role, role);
        handleAttribute("role", role);
    }
104488
public boolean hasRole(String roleName){
        if (roles != null) {
            for (String r : roles) {
                if (r.equals(roleName))
                    return true;
            }
        }
        return false;
    }
1305341
public function main()
    {
        $this->info('Task: import system roles');
        $this->hr();

        $roles = Configure::read('RolesCapabilities.Roles');
        if (empty($roles)) {
            $this->warn("No roles configured for importing.  Nothing to do.");

            return true;
        }

        /**
         * @var \RolesCapabilities\Model\Table\RolesTable $table
         */
        $table = TableRegistry::get('RolesCapabilities.Roles');

        foreach ($roles as $role) {
            if (empty($role['name'])) {
                $this->warn("Skipping role without a name.");
                continue;
            }

            if ($table->exists(['name' => $role['name']])) {
                $this->warn("Role [" . $role['name'] . "] already exists. Skipping.");
                continue;
            }

            $this->info("Role [" . $role['name'] . "] does not exist. Creating.");
            $entity = $table->newEntity();
            $entity = $table->patchEntity($entity, $role);

            $group = $this->getGroupByRoleName($entity->get('name'));
            if (empty($group)) {
                $this->abort("Failed to fetch group [" . $entity->get('name') . "]");
            }

            $result = $table->save($entity);
            if (!$result) {
                $this->err("Errors: \n" . implode("\n", $this->getImportErrors($entity)));
                $this->abort("Failed to create role [" . $entity->get('name') . "]");
            }

            $msg = 'Role [' . $entity->get('name') . '] imported';
            // associate imported role with matching group
            if ($table->Groups->link($entity, [$group])) {
                $msg .= ' and associated with group [' . $group->get('name') . ']';
            }
            $msg .= ' successfully';

            $this->info($msg);
        }

        $this->success('System roles imported successfully');
    }