Sets the role to upgrade name.

@param string $roleToUpgrade The role to upgrade name
496168
public function setRoleToUpgrade($roleToUpgrade)
    {
        Validate::isString($roleToUpgrade, 'roleToUpgrade');
        Validate::notNullOrEmpty($roleToUpgrade, 'roleToUpgrade');

        $this->_roleToUpgrade = $roleToUpgrade;
    }
623216
protected function assign(?string $role = null, ?string $action = null, bool $allow = true): void
    {
        $role = $this->roles->findKey($role);
        $action = $this->actions->findKey($action);

        if (! \is_null($role) && ! \is_null($action)) {
            $this->acl["{$role}:{$action}"] = $allow;
        }
    }
68151
public function upgradeToRole(Role $role): bool
    {
        $auth = \Yii::$app->getAuthManager();
        if ($auth->assign($role, $this->id)) {
            return true;
        }
        return false;
    }
325806
public function setPlatformRoles(User $user, $roles)
    {
        $this->roleManager->resetRoles($user);
        $this->roleManager->associateRoles($user, $roles);
    }
971907
public function addRole($roleName)
    {
        if (true === is_string($roleName) && false === in_array($roleName, $this->roles)) {
            $this->roles[] = $roleName;
        }
        return $this;
    }
134461
public function addRole($username, $role)
    {
        $user = $this->findUserByUsernameOrThrowException($username);
        if ($user->hasRole($role)) {
            return false;
        }

        $user->addRole($role);
        $this->userManager->updateUser($user);

        return true;
    }
1196414
private function _expandRole(&$roleList, $roleName, $depth = 0)
    {
        $role = $roleList[$roleName];

        if (isset($role['marked']) && $role['marked']) {
            return;
        }

        // possible circular reference!
        if ($depth > 5) {
            throw new \Exception("Possible circular reference detected while expanding role '{$roleName}'");
        }

        if (!empty($role['grl_parents'])) {
            $parents = $this->translateToRoleNames($role['grl_parents']);

            foreach ($parents as $parent) {
                $this->_expandRole($roleList, $parent, $depth + 1);
            }
        } else {
            $parents = array();
        }

        $this->_acl->addRole(new \Zend_Acl_Role($role['grl_name']), $parents);

        $privileges = array_filter(array_map('trim', explode(",", $role['grl_privileges'])));
        if ($privileges) {
            $this->_acl->addPrivilege($role['grl_name'], $privileges);
        }

        $roleList[$roleName]['marked'] = true;
    }
291711
public function setRolesAtOther($rolesAtOther)
    {
        $allowedValues = $this->getRolesAtOtherAllowableValues();
        if (!is_null($rolesAtOther) && array_diff($rolesAtOther, $allowedValues)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'rolesAtOther', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['rolesAtOther'] = $rolesAtOther;

        return $this;
    }
1165428
public function set_data($data) {
        $purpose = $this->get_persistent();

        $count = 0;
        foreach ($this->existingoverrides as $override) {
            $overridedata = $this->convert_existing_data_to_values($override->to_record());
            foreach ($overridedata as $key => $value) {
                $keyname = "roleoverride_{$key}[{$count}]";
                $data->$keyname = $value;
            }
            $count++;
        }

        parent::set_data($data);
    }
269023
protected function assign($role = null, $action = null, $allow = true)
    {
        $role   = $this->roles->findKey($role);
        $action = $this->actions->findKey($action);

        if (!is_null($role) && !is_null($action)) {
            $key             = $role . ':' . $action;
            $this->acl[$key] = $allow;
        }
    }
380966
public function update(Role $role, UpdateRole $request)
    {
        try {
            $role->update($request->except('permissions'));
            $role->syncPermissions($request->permissions());

            flash()->success(__('The :name role has been updated', ['name' => $role->name]));
        } catch (\Exception $e) {
            flash()->error(__('Error: :msg', ['msg' => $e->getMessage()]));
            return redirect()->back();
        }

        return redirect(route('appshell.role.show', $role));
    }
48717
public function setRole($role_id)
    {
        if (!empty($role_id) && $this->policy === Rule::NOINHERIT)
            throw new Exception("Rule::NOINHERIT can not be used in combination with a role");

        if ($role_id instanceof Role)
        {
            $this->role = $role_id;
            $role_id = $role_id->getID();
        }
        elseif (!is_scalar($role_id))
            throw new Exception("Role-ID must be a Role or a scalar");

        if ($role_id !== $this->role_id)
        {
            $this->changed = true;
            $this->role_id = $role_id;
        }
    }
1366208
public function inheritRole($roleName)
    {
        if (empty($roleName)) {
            throw new PropertyNotValid('Role name cannot be empty.');
        }

        if ($roleName === $this->getName()) {
            throw new PropertyNotValid('Role cannot be added to itself.');
        }

        if ($this->hasRole($roleName)) {
            return;
        }

        $this->roles[] = $roleName;
    }
602498
public function updateRole(RoleUpdateStruct $role)
    {
        try {
            return $this->innerGateway->updateRole($role);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
363456
public function attachRole($roleSlug)
    {
        // add dealer role to user
        $role = Role::where('keyword', $roleSlug)->first();
        $this->roles()->attach([$role->id]);

        return $this->roles;
    }
415766
protected function assign($role, $userId)
    {
        if (is_string($role)) {
            $role = $this->findRole($role);
        }

        echo "    > assigning $role->name to user $userId ...";
        $time = microtime(true);
        $this->authManager->assign($role, $userId);
        echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
    }
435342
public function assignRole($roleId = null)
    {
        $roles = $this->roles;

        if (! $roles->contains($roleId)) {
            return $this->roles()->attach($roleId);
        }

        return false;
    }