From b78d910ce4425d0058e72ce0c74a620da5c2ed83 Mon Sep 17 00:00:00 2001 From: "Kyle B. Johnson" Date: Fri, 6 Oct 2023 16:56:54 -0400 Subject: [PATCH 1/2] Refactor: Remove migrated form title suffix (#7004) --- src/FormMigration/Steps/FormTitle.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/FormMigration/Steps/FormTitle.php b/src/FormMigration/Steps/FormTitle.php index 3713660184..72fc609bc8 100644 --- a/src/FormMigration/Steps/FormTitle.php +++ b/src/FormMigration/Steps/FormTitle.php @@ -8,8 +8,7 @@ class FormTitle extends FormMigrationStep { public function process() { - $formTitle = sprintf('%s [form builder]', $this->formV2->title); - $this->formV3->title = $formTitle; - $this->formV3->settings->formTitle = $formTitle; + $this->formV3->title = $this->formV2->title; + $this->formV3->settings->formTitle = $this->formV2->title; } } From f6f2f4da5ff3644c5a8265550e598a734093f864 Mon Sep 17 00:00:00 2001 From: Jon Waldstein Date: Mon, 9 Oct 2023 10:20:57 -0400 Subject: [PATCH 2/2] Feature: update backwards compatibility for donation level id (#7002) Co-authored-by: Jon Waldstein --- ...nateControllerDonationCreatedListeners.php | 6 ++- .../Listeners/UpdateDonationLevelId.php | 42 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 src/DonationForms/Listeners/UpdateDonationLevelId.php diff --git a/src/DonationForms/Actions/DispatchDonateControllerDonationCreatedListeners.php b/src/DonationForms/Actions/DispatchDonateControllerDonationCreatedListeners.php index c5648d2e02..7e1f26ffda 100644 --- a/src/DonationForms/Actions/DispatchDonateControllerDonationCreatedListeners.php +++ b/src/DonationForms/Actions/DispatchDonateControllerDonationCreatedListeners.php @@ -1,11 +1,14 @@ getDonationForm(), $donation, $subscription, $formData->getCustomFields()); (new TemporarilyReplaceLegacySuccessPageUri())($formData, $donation); (new AddRedirectUrlsToGatewayData())($formData, $donation); + (new UpdateDonationLevelId())($formData->getDonationForm(), $donation); } } \ No newline at end of file diff --git a/src/DonationForms/Listeners/UpdateDonationLevelId.php b/src/DonationForms/Listeners/UpdateDonationLevelId.php new file mode 100644 index 0000000000..dc886cd356 --- /dev/null +++ b/src/DonationForms/Listeners/UpdateDonationLevelId.php @@ -0,0 +1,42 @@ +schema()->getNodeByName('amount'); + + if (!$amountField) { + return; + } + + $donationLevel = array_search( + (float)$donation->intendedAmount()->formatToDecimal(), + $amountField->getLevels(), + true + ); + + if ($donationLevel !== false) { + $donation->levelId = (string)$donationLevel; + $donation->save(); + } + } +} \ No newline at end of file