public function hasRole($roleName, $includeGroup = true)
    {
        $roles = $this->getEntityRoles($includeGroup);
        $roleNames = array_map(function (Role $role) {
            return $role->getName();
        }, $roles);

        return in_array($roleName, $roleNames);
    }
public function hasRole($roleName, $includeGroup = true)
    {
        $roles = $this->getEntityRoles($includeGroup);
        $roleNames = array_map(function (Role $role) {
            return $role->getName();
        }, $roles);

        return in_array($roleName, $roleNames);
    }
public function hasRole ( $ roleName , $ includeGroup = true ) { $ roles = $ this -> getEntityRoles ( $ includeGroup ) ; $ roleNames = array_map ( function ( Role $ role ) { return $ role -> getName ( ) ; } , $ roles ) ; return in_array ( $ roleName , $ roleNames ) ; }
Checks if the user has a given role.

@param bool   $includeGroup
@param string $roleName

@return bool
Checks if the user has a given role .