diff --git a/src/Security/UserClassBuilder.php b/src/Security/UserClassBuilder.php index fcc57319c4..88e6681e91 100644 --- a/src/Security/UserClassBuilder.php +++ b/src/Security/UserClassBuilder.php @@ -264,14 +264,16 @@ private function addEraseCredentials(ClassSourceManipulator $manipulator): void private function addUniqueConstraint(ClassSourceManipulator $manipulator, UserClassConfiguration $userClassConfig): void { - if ($userClassConfig->isEntity()) { - $manipulator->addAttributeToClass( - 'ORM\\UniqueConstraint', - [ - 'name' => 'UNIQ_IDENTIFIER_'.strtoupper(Str::asSnakeCase($userClassConfig->getIdentityPropertyName())), - 'fields' => [$userClassConfig->getIdentityPropertyName()], - ] - ); + if (!$userClassConfig->isEntity()) { + return; } + + $manipulator->addAttributeToClass( + 'ORM\\UniqueConstraint', + [ + 'name' => 'UNIQ_IDENTIFIER_'.strtoupper(Str::asSnakeCase($userClassConfig->getIdentityPropertyName())), + 'fields' => [$userClassConfig->getIdentityPropertyName()], + ] + ); } }