Add a single role. The argument is a string, integer, or instance of BridgeRole

@param $role string|integer|\Searsaw\Drawbridge\Models\BridgeRole

@throws \InvalidArgumentException

@return \Searsaw\Drawbridge\Models\BridgeRole
556282
public function addSingleRole($role)
    {
        if (is_string($role))
            return $this->addRoleByName($role);
        elseif (is_numeric($role))
            return $this->addRoleById($role);
        elseif ($role instanceof BridgeRole)
            return $this->addRoleByObject($role);
        else
            throw new \InvalidArgumentException('Role must be a name, ID, or Role object.');
    }
1118984
public function addRole($role)
    {
        if ($this->instance instanceof \Phavour\Session\Storage) {
            if ($this->hasRole($role)) {
                return true;
            }
            if ($this->instance->isLocked()) {
                $this->instance->unlock();
            }
            $roles = $this->instance->get('roles');
            if (is_array($roles)) {
                $this->instance->set(
                    'roles', array_merge($roles, array($role)));
            } else {
                $this->instance->set('roles', array($role));
            }
            $this->instance->lock();
            return true;
        }

        return false;
    }
580170
public function setRoleType($roleType)
    {
        $allowedValues = $this->getRoleTypeAllowableValues();
        if (!in_array($roleType, $allowedValues)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'roleType', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['roleType'] = $roleType;

        return $this;
    }
1023683
public function attachRole(...$roles)
    {
        $this->eachRole($roles, function($role) {
            if (! $this->hasRole($role)) {
                $this->roles()->attach($role->id);
            }
        });

        return $this;
    }
748480
public static function roleGrant($role) {
		// add roles
		if (!empty($role)) {
			// initialize roles array
			if (!isset($_SESSION['numbers']['user']['roles'])) {
				$_SESSION['numbers']['user']['roles'] = [];
			}
			if (!is_array($role)) $role = [$role];
			$_SESSION['numbers']['user']['roles'] = array_unique(array_merge($_SESSION['numbers']['user']['roles'], $role));
		}
	}
939534
private function addRule($role, $resource, $privileges, $isAllowed)
    {
        $role = $this->roles->get($role);

        if (is_scalar($resource)) {
            $resource = new Resource($resource, $this->defaultResourceMatcher);
        } elseif (!$resource instanceof ResourceInterface) {
            throw new \InvalidArgumentException('$resource is expected to be of type string or Gobline\Acl\ResourceInterface');
        }

        if (!is_array($privileges)) {
            $privileges = [$privileges];
        }
        foreach ($privileges as $privilege) {
            if (is_scalar($privilege)) {
                $privilege = new Privilege($privilege);
            } elseif (!$privilege instanceof Privilege) {
                throw new \InvalidArgumentException('$privileges elements are expected to be of type string or Gobline\Acl\Privilege');
            }
            $rule = new Rule($role, $resource, $privilege, $isAllowed);
            array_unshift($this->rules, $rule); // last rule added is the first to be evaluated
        }

        return $this;
    }
1193664
public function iAmLoggedInAsRole(string $role)
    {
        $found_user = null;
        $users      = $this->getWordpressParameter('users');

        foreach ($users as $user) {
            if (in_array($role, $user['roles'], true)) {
                $found_user = $user;
                break;
            }
        }

        if ($found_user === null) {
            throw new RuntimeException("[W801] User not found for role \"{$role}\"");
        }

        $this->logIn($found_user['username'], $found_user['password']);
    }
568081
public function prepareRole($role)
    {
        if ($role instanceof Role) {
            return $role;
        }

        if (is_numeric($role)) {
            return Role::whereId($role)->first();
        }

        return Role::whereName($role)->first();
    }
768904
public function word(string $role, string $text): ContainerElement
    {
        /** @var ContainerElement $this */
        return $this->addElement(Word::factory($role, $text));
    }
356133
function resolve($role) {
        if($role instanceof \CharlotteDunois\Yasmin\Models\Role) {
            return $role;
        }
        
        if(\is_int($role)) {
            $role = (string) $role;
        }
        
        if(\is_string($role) && parent::has($role)) {
            return parent::get($role);
        }
        
        throw new \InvalidArgumentException('Unable to resolve unknown role');
    }
1069649
private function getRule($role, $resource, $privilege)
    {
        $role = $this->roles->get($role);

        if (is_scalar($resource)) {
            $resource = new Resource($resource);
        } elseif (!$resource instanceof ResourceInterface) {
            throw new \InvalidArgumentException('$resource is expected to be of type string or Gobline\Acl\ResourceInterface');
        }

        if (is_scalar($privilege)) {
            $privilege = new Privilege($privilege);
        } elseif (!$privilege instanceof Privilege) {
            throw new \InvalidArgumentException('$privilege is expected to be of type string or Gobline\Acl\Privilege');
        }

        foreach ($this->rules as $rule) {
            if (!$rule->getRole()->equals($role)) {
                continue;
            }
            if (!$rule->getPrivilege()->equals($privilege) && !$rule->getPrivilege()->equals('*')) {
                continue;
            }
            if (!$rule->getResource()->matches($resource) && (!$rule->getResource() instanceof Resource || !$rule->getResource()->matches('*'))) {
                continue;
            }

            return $rule;
        }

        foreach ($role->getParents() as $role) {
            $rule = $this->getRule($role, $resource, $privilege);
            if ($rule !== null) {
                return $rule;
            }
        }

        return null;
    }
1240864
public function removeRole(string $role): GroupInterface
    {
        if (false !== $key = array_search(mb_strtoupper($role), $this->roles, true)) {
            unset($this->roles[$key]);
            $this->roles = array_values($this->roles);
        }

        return $this;
    }
10475
public function setRoleUnauthenticated($role)
    {
        $role = (string) $role;
        if ($role === '') {
            throw new \InvalidArgumentException('$role cannot be empty');
        }

        $this->roleUnauthenticated = $role;
    }
618082
public function addRoleByName($role_name)
    {
        $role = static::$app['db']->connection()
            ->table('roles')->where('name', '=', $role_name)->first();

        if (! $role)
            throw new \RuntimeException('No role with that name found.');

        if (is_array($role))
            return $this->addRoleById($role['id']);
        elseif (is_object($role))
            return $this->addRoleById($role->id);
        else
            throw new \UnexpectedValueException('Value returned not array or instance of BridgeRole.');
    }
804832
public function update(Role $role)
    {
        $this->validate($this->request, [
            'name'        => 'required',
            'slug'        => 'required|unique:roles,slug,' . $role->id,
        ]);

        $role->name = $this->request->get('name');
        if (! $role->system) {
            $role->slug = $this->request->get('slug');
        }
        $role->save();

        $role->syncPermissions($this->request->get('permissions', []));
        flash()->success('Role ' . $role->name . ' successfully updated!');

        return redirect()->route('administrator.roles.index');
    }
39604
public function addRole($id, $role)
    {
        if (empty($role) || !$user = $this->getUser($id)) {
            return false;
        }

        // Add the role to the $user['roles'] array
        $user['roles'][] = $role;

        return $this->saveUser($user);
    }
1271338
public function addRole($role): RouteInterface
    {
        if (is_string($role)) {
            $this->roles[] = new GenericRole($role);
        } elseif (!$role instanceof RoleInterface) {
            throw new InvalidArgumentException(
                'addRole() expects $role to be of type Zend\Permissions\Acl\Role\RoleInterface'
            );
        }

        return $this;
    }