@param int $role OPTIONAL

@return int|null
355656
public function getPeriod($role = null) {
        $roles = $this->_get('roles');
        if (!isset($roles[$role])) {
            if ($role === null) {
                return null;
            }
            return $this->getPeriod();
        }
        return (int) $roles[$role]['period'];
    }
303209
public function count_users( $role ) {

		$count_users = count_users();

		$avail_roles = array();

		foreach ( $count_users['avail_roles'] as $count_role => $count ) {
			$avail_roles[ $count_role ] = $count;
		}

		if ( empty( $role ) ) {
			return $avail_roles;
		}

		if ( ! isset( $avail_roles[ $role ] ) ) {
			$avail_roles[ $role ] = 0;
		}

		return $avail_roles[ $role ];
	}
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();
        
    }
960731
public static function hasRoleId($role)
    {
        return (self::isFeUser()
            && self::isAuthenticated()
            && in_array($role, $GLOBALS['TSFE']->fe_user->groupData['uid'])
        );
    }
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);
    }
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]);
        }
    }
437167
public function inRole($role): bool
    {
        $role = Arr::first($this->roles, function ($instance) use ($role) {
            if ($role instanceof RoleInterface) {
                return $instance->getRoleId() === $role->getRoleId();
            }
            if ($instance->getRoleId() === $role || $instance->getRoleSlug() === $role) {
                return true;
            }

            return false;
        });

        return $role !== null;
    }
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()
        ;
    }
565871
public static function getRoleACL($role)
    {
        global $PPHP;
        $db = $PPHP['db'];

        $flat = $db->selectArray(
            "
            SELECT action, objectType, objectId
            FROM acl_roles
            WHERE role=?
            ",
            array($role)
        );
        return is_array($flat) ? $flat : array();
    }
729184
public static function get(string $role): OODBBean {
		self::check();
		$r = new self($role);

		return $r->getRole();
	}
936342
public function isUserInRole(String $role)
    {

        // query whether or not we've an user principal
        if ($principal = $this->getUserPrincipal()) {
            return $principal->getRoles()->contains($role);
        }

        // user is not in passed role
        return false;
    }
11135
public function deleteRole(Role $role)
    {
        $returnValue = $this->service->deleteRole($role);
        $this->signalDispatcher->emit(
            new DeleteRoleSignal(
                array(
                    'roleId' => $role->id,
                )
            )
        );

        return $returnValue;
    }
641367
public function hasRole($role)
    {
        if (is_string($role)) {
            return $this->roles->contains('name', $role);
        }

        if (is_array($role)) {
            foreach ($role as $r) {
                if ($this->hasRole($r)) {
                    return true;
                }
            }

            return false;
        }

        return !!$role->intersect($this->roles)->count();
    }
558616
public static function getRoleUsers($role)
    {
        global $PPHP;
        $db = $PPHP['db'];

        $out = $db->selectList(
            "
            SELECT userId FROM users_roles
            WHERE role=?
            ORDER BY userId ASC
            ",
            array($role)
        );
        return (is_array($out) ? $out : array());
    }
977680
public function get($role)
    {
        if (is_scalar($role)) {
            $role = new Role($role);
        } elseif (!$role instanceof Role) {
            throw new \InvalidArgumentException('$role is expected to be of type string or Gobline\Acl\Role');
        }

        $roleName = $role->getName();

        if (!$this->has($role)) {
            throw new \InvalidArgumentException('Role "'.$roleName.'" not found');
        }

        return $this->roles[$roleName];
    }
229756
public function hasRole($role)
    {
        $role = strtoupper($role);

        if ($role == 'ROLE_USER') {
            return true;
        }

        if (in_array($role, $this->roles)) {
            return true;
        }

        return false;
    }
395801
public function createRole(Role $role)
    {
        try {
            return $this->innerGateway->createRole($role);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }