public function allowPersist(ClassMetadata $cm, $field)
{
$groupsAnnotation = $this->reader->getPropertyAnnotation($cm->getReflectionProperty($field), 'Symfony\\Component\\Serializer\\Annotation\\Groups');
if ($groupsAnnotation !== null) {
if (in_array("readonly", $groupsAnnotation->getGroups())) {
return false;
}
}
return true;
}