From 33870f00b83775ad98300690640b7e171165e9cc Mon Sep 17 00:00:00 2001 From: Fan2Shrek Date: Tue, 19 Mar 2024 18:32:21 +0100 Subject: [PATCH] Rebase main --- src/Controller/ProfileController.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Controller/ProfileController.php b/src/Controller/ProfileController.php index 24fcdb71d..ed19a5bd4 100644 --- a/src/Controller/ProfileController.php +++ b/src/Controller/ProfileController.php @@ -121,24 +121,26 @@ public function editAction(Request $request, UserNotifier $userNotifier): Respon } $oldEmail = $user->getEmail(); + $oldUsername = $user->getUsername(); $form = $this->createForm(ProfileFormType::class, $user); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { - $uow = $this->getEM()->getUnitOfWork(); - $uow->computeChangeSets(); - $changeSet = $uow->getEntityChangeSet($user); + $diffs = array_filter([ + $oldEmail !== $user->getEmail() ? 'email' : null, + $oldUsername !== $user->getUsername() ? 'username' : null, + ]); - $diffs = array_intersect(array_keys($changeSet), ['email', 'username']); - - if (!empty($diffs) && $user instanceof User) { + if (!empty($diffs)) { $reason = sprintf('Your %s has been changed', implode(' and ', $diffs)); - $userNotifier->notifyChange($changeSet['email'][0] ?? $user->getEmail(), $reason); - } - if ($oldEmail !== $user->getEmail()) { - $user->resetPasswordRequest(); + if ($oldEmail !== $user->getEmail()) { + $userNotifier->notifyChange($oldEmail, $reason); + $user->resetPasswordRequest(); + } + + $userNotifier->notifyChange($user->getEmail(), $reason); } $this->getEM()->persist($user);