Skip to content

Commit 5bed64d

Browse files
committed
[DoctrineBridge] Restore compatibility with Doctrine ODM by validating $class object type
1 parent ef36093 commit 5bed64d

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

Validator/Constraints/UniqueEntityValidator.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Bridge\Doctrine\Validator\Constraints;
1313

14-
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
1514
use Doctrine\Persistence\ManagerRegistry;
1615
use Doctrine\Persistence\Mapping\ClassMetadata;
1716
use Doctrine\Persistence\ObjectManager;
@@ -93,7 +92,7 @@ public function validate(mixed $entity, Constraint $constraint)
9392
throw new ConstraintDefinitionException(sprintf('The field "%s" is not mapped by Doctrine, so it cannot be validated for uniqueness.', $fieldName));
9493
}
9594

96-
if (property_exists(OrmClassMetadata::class, 'propertyAccessors')) {
95+
if (property_exists($class, 'propertyAccessors')) {
9796
$fieldValue = $class->propertyAccessors[$fieldName]->getValue($entity);
9897
} else {
9998
$fieldValue = $class->reflFields[$fieldName]->getValue($entity);

0 commit comments

Comments
 (0)