Creates a new Role object.
Note that the newly created role is not added to the RBAC system yet.
You must fill in the needed data and call [[add()]] to add it to the system.

@param string $name the role name

@return Role the new Role object
774250
public function createRole($name) {
		$result = $this->repository->createRole($name);
		$this->domain->const->generateRoles();
		return $result;
	}
848148
public function hasRole($name)
    {
        if ($this->RoleID) {
            $role = new Role($this->RoleID);
            if ($role->RoleName == $name) {
                return true;
            }
        }

        foreach ($this->Roles as $role) {
            if ($role->RoleName == $name) {
                return true;
            }
        }
        return false;
    }
1176049
public function editRoleNameAction(Role $role, $name)
    {
        if (ctype_space($name)) {
            return new JsonResponse(
                array(
                    'name' => $role->getName(),
                    'limit' => $role->getMaxUsers(),
                    'translationKey' => $role->getTranslationKey()
                ),
                500
            );
        }

        $role->setTranslationKey($name);
        $this->roleManager->edit($role);

        return new JsonResponse(
            array(
                'name' => $role->getName(),
                'limit' => $role->getMaxUsers(),
                'translationKey' => $role->getTranslationKey()
            )
        );
    }
863948
private function createUserWithRole(Role $role)
    {
        $userService = $this->getRepository()->getUserService();
        $username = uniqid($role->identifier, true);
        $createStruct = $userService->newUserCreateStruct(
            $username,
            $username . '@example.com',
            self::$password,
            'eng-GB'
        );
        $createStruct->setField('first_name', $username);
        $createStruct->setField('last_name', 'The first');
        $user = $userService->createUser($createStruct, [$userService->loadUserGroup(self::$groupId)]);

        $this->getRepository()->getRoleService()->assignRoleToUser($role, $user);

        return $user;
    }
1213497
public function createBaseRole($name, $translationKey, $isReadOnly = true, $makeGroup = false)
    {
        $role = new Role();
        $role->setName($name);
        $role->setTranslationKey($translationKey);
        $role->setReadOnly($isReadOnly);
        $role->setPersonalWorkspaceCreationEnabled(true);
        $role->setType(Role::PLATFORM_ROLE);
        $this->om->persist($role);

        if ($makeGroup) {
            $group = new Group();
            $group->setName($name);
            $group->setReadOnly($isReadOnly);
            $group->addRole($role);
            $this->om->persist($group);
        }

        $this->om->flush();

        return $role;
    }
790989
def role_create(name, profile=None, **connection_args):
    '''
    
    '''

    kstone = auth(profile, **connection_args)
    if 'Error' not in role_get(name=name, profile=profile, **connection_args):
        return {'Error': 'Role "{0}" already exists'.format(name)}
    kstone.roles.create(name)
    return role_get(name=name, profile=profile, **connection_args)
736988
public function newFriendRequestAction($name)
    {
        $logFile = $this->container->getParameter('claroline.param.claroline_log');
        $host = $this->request->query->get('host');
        //uncomment this for debugging puroposes...

        if ($this->container->get('kernel')->getEnvironment() === 'dev') {
            $fileLogger = new \Monolog\Logger('claroline.debug.log');
            $fileLogger->pushHandler(new \Monolog\Handler\StreamHandler($logFile));
            $fileLogger->addInfo(var_export($this->oauthManager->isAutoCreated($host), true));
        }

        $this->oauthManager->addPendingFriendRequest(
            $name,
            $host,
            $this->oauthManager->isAutoCreated($host)
        );

        return new JsonResponse(array('name' => $name, 'host' => $host));
    }
1232992
protected function findRole($name)
    {
        $role = $this->authManager->getRole($name);

        if ($role instanceof Role) {
            return $role;
        }

        return null;
    }
1038887
protected function addRole($groupName, $name)
    {

        // load the application
        $application = RequestHandler::getApplicationContext();

        // query whether or not, the group already exists
        if ($this->setsMap->exists($groupName) === false) {
            $group = new SimpleGroup(new String($groupName));
            $this->setsMap->add($groupName, $group);
        } else {
            $group = $this->setsMap->get($groupName);
        }

        try {
            // finally add the identity to the group
            $group->addMember($this->createIdentity(new String($name)));

        } catch (\Exception $e) {
            $application->getNamingDirectory()
                        ->search(NamingDirectoryKeys::SYSTEM_LOGGER)
                        ->error($e->__toString());
        }
    }
286826
public function hasRoleForUser($name, $role)
    {
        $roles = $this->getRolesForUser($name);

        $hasRole = false;
        foreach ($roles as $r) {
            if ($r == $role) {
                $hasRole = true;

                break;
            }
        }

        return $hasRole;
    }
536411
public function action(string $name) : ActionDefiner
    {
        return new ActionDefiner($this->authSystem, $this->requiredPermissions, $name, function (IAction $action) {
            $this->actions[$action->getName()] = $action;
        });
    }
931175
public static function create($name = 'null') {
    $is_upper = FormatterFactory::getDefaultFormatter()->getConfig('boolean_null_upper');
    $node = new NullNode();
    $node->addChild(NameNode::create($is_upper ? 'NULL' : 'null'), 'constantName');
    return $node;
  }
475256
protected function createHeader($name)
    {
        $new = clone $this;

        $normalized = strtolower($name);

        $name = HeaderHelper::normalizeHeaderName($name);

        $new->headerNames[$normalized] = $name;
        $new->headers[$name] = [];

        return $new;
    }
617004
public function getRole($name)
    {
        if ($this->hasRole($name)) {
            return $this->roles[$name];
        }

        throw new \InvalidArgumentException(sprintf('No role with name "%s" could be found', $name));
    }
933875
public function assignRole ($name)
		{
			$auth = Yii::$app->getAuthManager();
			$role = $auth->getRole($name);
			if ($role)
				$auth->assign($role, $this->id);
		}
203665
public static function named(string $name) : Permission
    {
        if (!isset(self::$permissionCache[$name])) {
            self::$permissionCache[$name] = new self($name);
        }

        return self::$permissionCache[$name];
    }
663809
public function createAccount($name = null)
    {
        $account = new $this->accountFqcn($name);
        $account->setOrganization($this->oh->getOrganization());

        return $account;
    }