Add a new role.

Provide a role object that represents the role you wish to add.

@param \Jaspersoft\Dto\Role\Role $role
@throws \Jaspersoft\Exception\RESTRequestException
500990
public function createRole(Role $role)
    {
        $url = self::makeUrl($role->tenantId, $role->name);
        $this->service->prepAndSend($url, array(201, 200), 'PUT', json_encode($role), false, 'application/json', 'application/json');
    }
121315
public function addRole(\Amulen\UserBundle\Entity\Role $role)
    {
        $this->roles[] = $role;

        return $this;
    }
957350
public function addRoles(Collection $roles)
    {
        foreach($roles as $role){
            $this->roles->add($role);
        }
        
    }
654806
protected function _addRoles(array $roles) {
        foreach ($roles as $roleName => $properties) {
            // If the properties aren't set as an array, then we will consider
            // the value as the role ID.
            if (!is_array($properties)) {
                $properties = array('id' => $properties);
            }

            $id = $properties['id'];

            if (is_null($id) || empty($id)) {
                throw new Zend_Application_Resource_Exception(
                    sprintf(
                        $this->_missingPropertyMessage, 'ID', 'role', $roleName
                    )
                );
            }
            $this->_addRoleById($roles, $id);
        }
    }
731532
def add_role(self, role):
        
        schema = RoleSchema()
        ok = schema.process(role)
        if not ok or not role.id:
            err = 'Role must be valid and saved before adding to user'
            raise x.UserException(err)

        self.__roles.append(role)
971907
public function addRole($roleName)
    {
        if (true === is_string($roleName) && false === in_array($roleName, $this->roles)) {
            $this->roles[] = $roleName;
        }
        return $this;
    }
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;
    }
1124239
public function setAllowed($role = self::ALL, $resource = self::ALL, $privilege = self::ALL)
    {
        if ($this->policy == self::POLICY_ALLOW) {
            $this->permission->allow($role, $resource, $privilege);
        } else {
            $this->permission->deny($role, $resource, $privilege);
        }
    }
828740
public function addRole($role, $inherits = null)
    {
        if (is_string($role)) {
            $name = $role;
            $role = $this->createRole($name);
        } elseif ($role instanceof RoleInterface) {
            $name = $role->getName();
        } else {
            throw new \InvalidArgumentException('Role must be a string or implement RoleInterface');
        }

        if ($inherits) {

            if (!is_array($inherits)) {
                $inherits = [$inherits];
            }

            foreach ($inherits as $inherit) {
                $role->inherit($this->getRole($inherit));
            }
        }

        $this->roles[$name] = $role;
        return $role;
    }
29291
public function addAllowedRole($role, $attribute = 'access')
    {
        $roleStr = (string) $role;
        if (!isset($this->allowedRoles[$roleStr])) {
            $this->allowedRoles[$roleStr] = array();
        }
        $this->allowedRoles[$roleStr][(string) $attribute] = true;
        return $this;
    }
1063581
public function addRole(Role $role)
    {
        if ($role->isAbstract()) {
            throw new \InvalidArgumentException(sprintf('Abstract roles can\'t be assigned to accounts directly, but the role "%s" is marked abstract', $role->getIdentifier()), 1399900657);
        }
        $this->initializeRoles();
        if (!$this->hasRole($role)) {
            $roleIdentifier = $role->getIdentifier();
            $this->roleIdentifiers[] = $roleIdentifier;
            $this->roles[$roleIdentifier] = $role;
        }
    }
67131
public function attachRole($role)
    {
        if (! $this->hasRole($role->name)) {
            $this->roles()->attach($role);
        }
    }
945554
def add_role_to_user(self, role, user):
        
        uri = "users/%s/roles/OS-KSADM/%s" % (utils.get_id(user),
                utils.get_id(role))
        resp, resp_body = self.method_put(uri)
1281147
public function addRole($role)
    {
        $role = strtoupper($role);
        if (static::ROLE_DEFAULT === $role) {
            return $this;
        }

        if (!$this->hasRole($role)) {
            $this->roles[] = $role;
        }

        return $this;
    }
1072967
public function removeRoleAction(Role $role)
    {
        $this->roleManager->remove($role);

        return new JsonResponse(
            array(
                'name' => $role->getName(),
                'limit' => $role->getMaxUsers(),
                'translationKey' => $role->getTranslationKey()
            )
        );
    }
276688
public function removeRole(string $role): PermissionManager
    {
        if (!$this->hasRole($role)) {
            throw new RoleException("Undefined role '{$role}'");
        }

        unset($this->permissions[$role]);

        return $this;
    }
1159261
public function addRole($roleName)
    {
        if (empty($roleName)) {
            throw new PropertyNotValid('Role name cannot be empty.');
        }

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

        $this->roles[] = $roleName;
    }