Includes the $roleToInclude Role to the $role Role.

@param core_kernel_classes_Resource $role A Role.
@param core_kernel_classes_Resource $roleToInclude A Role to include.
197305
public function includeRole(core_kernel_classes_Resource $role,  core_kernel_classes_Resource $roleToInclude)
	{
		$this->generisUserService->includeRole($role, $roleToInclude);
        $this->getEventManager()->trigger(new RoleChangedEvent($role->getUri(), 'included role', $roleToInclude->getUri()));
    }
277459
public function attachRole($role, $reload = true)
    {
        if ($this->hasRole($role)) return;

        event(new AttachingRoleToPermission($this, $role));
        $this->roles()->attach($role);
        event(new AttachedRoleToPermission($this, $role));

        $this->loadRoles($reload);
    }
26187
public function addParentRole(Role $parentRole)
    {
        if (!$this->hasParentRole($parentRole)) {
            $parentRoleIdentifier = $parentRole->getIdentifier();
            $this->parentRoles[$parentRoleIdentifier] = $parentRole;
        }
    }
1223098
public function storeRolePermission(Role $role, Permission $permission)
    {
        $this->getTable()->insert([
            'role' => $role->getRoleName(),
            'type' => $permission->getType(),
            'action' => $permission->getAction(),
            'resource_type' => $permission->getResourceType(),
            'resource_id' => $permission->getResourceId(),
        ]);

        $this->resetPermissionsCacheForRole($role);
    }
1191852
public function addRole(RoleInterface $role)
    {
        $this->roles->add($role);

        if ($role->hasUser($this) === false)
            $role->addUser($this);

        return $this;
    }
569749
public function getRolePermissions(Role $role)
    {
        $key = $this->getRoleKey($role);

        // If we've saved the caller permissions we don't need to fetch them again.
        if (array_key_exists($key, $this->rolePermissions)) {
            return $this->rolePermissions[$key];
        }

        $results = $this->getTable()->where('role', $role->getRoleName())->get()->toArray();

        return $this->rolePermissions[$key] = PermissionFactory::createFromData($results);
    }
315715
public function attachRole($role)
    {
        return (!$this->getRoles()->contains($role)) ? $this->roles()->attach($role) : true;
    }
729819
public function deleteRole($roleId, $status = Role::STATUS_DEFINED)
    {
        $role = $this->loadRole($roleId, $status);

        foreach ($role->policies as $policy) {
            $this->roleGateway->removePolicy($policy->id);
        }

        $this->roleGateway->deleteRole($role->id, $status);
    }
1066398
protected function hasRole(TokenInterface $token, $role)
    {
        $roles = $token->getRoles();
        foreach ($roles as $checkRole) {
            if (($checkRole instanceof RoleInterface && $role === $checkRole->getRole()) ||
                (is_string($checkRole) && $role === $checkRole)
            ) {
                return true;
            }
        }

        return false;
    }
793938
public function removeRole( core_kernel_classes_Resource $role)
    {
        $returnValue = (bool) false;
        
    	if (GENERIS_CACHE_USERS_ROLES == true && core_kernel_users_Cache::areIncludedRolesInCache($role)){	
    		
    		if ($role->delete(true) == true){ // delete references.
        		$returnValue = core_kernel_users_Cache::removeIncludedRoles($role);
        		
        		// We also need to remove all included roles cache that contain
        		// the role we just deleted.
        		foreach ($this->getAllRoles() as $r){
        			if (array_key_exists($role->getUri(), $this->getIncludedRoles($r))){
        				core_kernel_users_Cache::removeIncludedRoles($r);
        			}
        		}
        	}
        	else{
        		$roleUri = $role->getUri();
        		$msg = "An error occured while removing role '${roleUri}'. It could not be deleted from the cache.";
        		throw new core_kernel_users_Exception($msg);
        	}
        }
        else{
        	$returnValue = $role->delete(true);	// delete references to this role!
        }

        return (bool) $returnValue;
    }
625051
public function join(RoleInterface $role)
    {
        $this->roles()
            ->attach($role);

        return $this->is($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());
            }
        }
    }
972986
public function removeRole(RoleInterface $role)
    {
        $this->roles->removeElement($role);

        if ($role->hasUser($this) === true)
            $role->removeUser($this);
        
        return $this;
    }
582395
public function getSubRoles(Role $role) {
		
		$parentName = $role->getRoleName();
		$subRoles = [];
		
		if(array_key_exists($role->getRoleName(), $this->mappedRoleNames)) {
			
			foreach($this->mappedRoleNames[$parentName] as $subRoleName) {
				$subRoles[] = new Role($subRoleName);
			}
			
		}
		
		return $subRoles;

	}
1353211
public function findRecursiveByResourceAndRole(ResourceNode $resource, Role $role)
    {
        $dql = "
            SELECT rights, role, resource
            FROM Claroline\CoreBundle\Entity\Resource\ResourceRights rights
            JOIN rights.resourceNode resource
            JOIN rights.role role
            WHERE resource.path LIKE :path AND role.name = :roleName
        ";

        $query = $this->_em->createQuery($dql);
        $query->setParameter('path', $resource->getPath().'%');
        $query->setParameter('roleName', $role->getName());

        return $query->getResult();
    }
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;
    }
1191297
protected function addRolesToSU(Role $roleSu)
    {
        $this->stdout("Init SU assigning roles\n",  Console::FG_YELLOW);
        foreach ($this->authManager->getRoles() as $role) {
            try {
                if ($role->name !== $roleSu->name) {
                    $this->authManager->addChild($roleSu, $role);
                    $this->stdout("\tAssign to SU role: {$role->name} - success\n", Console::FG_GREEN);
                }
            } catch(\Exception $e) {
                $this->stdout("\t- already exist\n",  Console::FG_RED);
            }
        };
    }