[Validator] Validate object with it's own entity manager by default

This commit is contained in:
Marek Kalnik 2011-09-15 10:42:38 +02:00
parent 5526072dba
commit 4ca09a931d

View File

@ -54,7 +54,11 @@ class UniqueEntityValidator extends ConstraintValidator
throw new ConstraintDefinitionException("At least one field has to be specified.");
}
$em = $this->registry->getEntityManager($constraint->em);
if ($constraint->em) {
$em = $this->registry->getEntityManager($constraint->em);
} else {
$em = $this->registry->getEntityManagerForClass(get_class($entity));
}
$className = $this->context->getCurrentClass();
$class = $em->getClassMetadata($className);