[DoctrineBridge] Initialize proxies in UniqueEntityValidator

Fixes #3163
This commit is contained in:
Jeremy Mikola 2012-04-13 14:12:49 -04:00
parent baabe2649e
commit 41bdf26cb2

View File

@ -78,6 +78,12 @@ class UniqueEntityValidator extends ConstraintValidator
}
if ($class->hasAssociation($fieldName)) {
/* Ensure the Proxy is initialized before using reflection to
* read its identifiers. This is necessary because the wrapped
* getter methods in the Proxy are being bypassed.
*/
$em->initializeObject($criteria[$fieldName]);
$relatedClass = $em->getClassMetadata($class->getAssociationTargetClass($fieldName));
$relatedId = $relatedClass->getIdentifierValues($criteria[$fieldName]);