Skip to content

Commit

Permalink
Early return if not entity
Browse files Browse the repository at this point in the history
Co-authored-by: Jesse Rushlow <40327885+jrushlow@users.noreply.github.com>
  • Loading branch information
maelanleborgne and jrushlow committed Feb 27, 2024
1 parent ec6fc21 commit b4b9710
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/Security/UserClassBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()],
]
);
}
}

0 comments on commit b4b9710

Please sign in to comment.