@param RoleInterface $role

@return int
358829
public function removeRole(RoleInterface $role): int
    {
        $result = $this->roles()->where('slug', $role->getRoleSlug())->first();

        $this->eventRemoveRole($role);

        return $this->roles()->detach($result);
    }
432725
public function removeRole(Role $role)
    {
        $this->initializeRoles();
        if ($this->hasRole($role)) {
            $roleIdentifier = $role->getIdentifier();
            unset($this->roles[$roleIdentifier]);
            $identifierIndex = array_search($roleIdentifier, $this->roleIdentifiers);
            unset($this->roleIdentifiers[$identifierIndex]);
        }
    }
194407
public function getAuthRoleName($role = null) {
		$role = (int)$role;
		$result = '';
		if ($role === 0) {
			return $result;
		}

		$roleNames = $this->_getAuthFieldsList('name');
		if (empty($roleNames)) {
			return $result;
		}

		if (!krsort($roleNames)) {
			return $result;
		}

		foreach ($roleNames as $roleMask => $roleName) {
			if (($role & $roleMask) === $roleMask) {
				$result = $roleName;
				break;
			}
		}

		return $result;
	}
123458
public function hasRole($role)
    {
        $roles = array_column($this->roles->toArray(), 'name');
        return array_search($role, $roles) > -1;
    }
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;
    }
379376
public function GetCountForRole($RoleID = '') {
      if (!is_array($RoleID))
         $RoleID = array($RoleID);
      
      return $this->SQL
         ->Select('a.ActivityID', 'count', 'ActivityCount')
         ->From('Activity a')
         ->Join('ActivityType t', 'a.ActivityTypeID = t.ActivityTypeID')
         ->Join('UserRole ur', 'a.ActivityUserID = ur.UserID')
         ->WhereIn('ur.RoleID', $RoleID)
         ->Where('t.Public', '1')
         ->Get()
         ->FirstRow()
         ->ActivityCount;
   }
150064
public function isAuthenticatedByRole(Role $role) {

		return !isset($this->auth) || $this->auth === $role->getRoleName();

	}
765879
public function findOneByRole($role)
    {
        $query = ' SELECT a'
                . ' FROM CoreBundle:BaseActor a'
                . " JOIN a.roles r  "
                . " WHERE r.role =  'ROLE_SUPER_ADMIN' "
                ;
        $q = $this->getEntityManager()->createQuery($query);
        return  $q->getOneOrNullResult();
        
    }
1120871
public function getRelativeRoleName($role)
    {
        $roles = $this->collectRelativeRoles();
        if (isset($roles[$role])) {
            return $roles[$role];
        }
    }
1050591
public function getCountByRole($role)
    {
        if (is_null($role)) {
            throw new \Exception('Role is required');
        }

        $result = 0;
        try {
            $users  = $this->_em->getRepository('\erdiko\users\entities\User')
                           ->findBy(array('role' => $role));
            $result  = count($users);

        }catch (\Exception $e) {
            \error_log($e->getMessage());
        }
        return $result;
    }
377985
public function remove(Role $role)
    {
        $role->delete();

        Alert::info(__('Role was removed'));

        return redirect()->route('platform.systems.roles');
    }
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;
    }
180588
protected function buildContexts(RoleInterface $role)
    {
        $contexts = null;

        if ($role instanceof OrganizationalInterface) {
            $contexts = [null !== $role->getOrganization() ? PermissionContexts::ORGANIZATION_ROLE : PermissionContexts::ROLE];
        }

        return $contexts;
    }
285871
public function findOneByRole($role)
    {
        $qb = $this->createQueryBuilder('g');

        return $qb
            ->andWhere($qb->expr()->like('g.roles', $qb->expr()->literal('%"'.strtoupper($role).'"%')))
            ->orderBy('g.position', 'DESC')
            ->setMaxResults(1)
            ->getQuery()
            ->getOneOrNullResult()
        ;
    }
450655
public function countUsersByRole(Role $role, $restrictionRoleNames = null, $organizations = null)
    {
        $qb = $this->createQueryBuilder('user')
            ->select('COUNT(DISTINCT user.id)')
            ->leftJoin('user.roles', 'roles')
            ->andWhere('roles.id = :roleId')
            ->andWhere('user.isEnabled = :enabled')
            ->setParameter('roleId', $role->getId())
            ->setParameter('enabled', true);
        if (!empty($restrictionRoleNames)) {
            $qb->andWhere('user.id NOT IN (:userIds)')
                ->setParameter('userIds', $this->findUserIdsInRoles($restrictionRoleNames));
        }
        if (null !== $organizations) {
            $qb->join('user.userOrganizationReferences', 'orgaRef')
                ->andWhere('orgaRef.organization IN (:organizations)')
                ->setParameter('organizations', $organizations);
        }
        $query = $qb->getQuery();

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

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

        return $this;
    }
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;
    }