public function canRemoveProperty($propertyName, $throw = false)
{
$propDefs = $this->getPropertyDefinitions();
foreach ($propDefs as $prop) {
if ($propertyName === $prop->getName() && ($prop->isMandatory() || $prop->isProtected())) {
if ($throw) {
if ($prop->isMandatory()) {
$errorMsg = "Can't remove the mandatory property: " . $prop->getName();
} else {
$errorMsg = "Can't remove the protected property: " . $prop->getName();
}
throw new ConstraintViolationException($errorMsg);
}
return false;
}
}
return true;
}