From b4b97107b1cb860f1fa3525fd4638c967fcfc7b0 Mon Sep 17 00:00:00 2001 From: maelanleborgne Date: Tue, 27 Feb 2024 16:35:00 +0100 Subject: [PATCH] Early return if not entity Co-authored-by: Jesse Rushlow <40327885+jrushlow@users.noreply.github.com> --- src/Security/UserClassBuilder.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) 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()], + ] + ); } }