id instanceof UserEntity ? $cmd->id : $this->repo->ofUniqueKey($cmd->id); $user->updatePassword( $cmd->currentPassword, $cmd->newPassword ); // Dispatch the user password updated event $event = new UserPasswordUpdatedEvent($user); $this->dispatcher->dispatch($event); return $user; } }