← All changes
|
src/FormMigration/Controllers/TransferController.php
+2
-30
4.16.8
→
3.21.1
View file →
| @@ -1,16 +1,16 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace Give\FormMigration\Controllers; |
| 4 | 4 | |
| 5 | -use Give\Campaigns\Repositories\CampaignRepository; | |
| 6 | -use Give\Campaigns\ValueObjects\CampaignType; | |
| 7 | 5 | use Give\DonationForms\V2\Models\DonationForm; |
| 6 | +use Give\DonationForms\ValueObjects\DonationFormStatus; | |
| 8 | 7 | use Give\FormMigration\Actions\GetMigratedFormId; |
| 9 | 8 | use Give\FormMigration\Actions\TransferDonations; |
| 10 | 9 | use Give\FormMigration\Actions\TransferFormUrl; |
| 11 | 10 | use Give\FormMigration\DataTransferObjects\TransferOptions; |
| 12 | 11 | use Give\Framework\Database\DB; |
| 12 | +use Give\Framework\QueryBuilder\QueryBuilder; | |
| 13 | 13 | use WP_REST_Request; |
| 14 | 14 | use WP_REST_Response; |
| 15 | 15 | |
| 16 | 16 | class TransferController |
| @@ -26,12 +26,8 @@ | ||
| 26 | 26 | { |
| 27 | 27 | $this->request = $request; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - /** | |
| 31 | - * @since 4.14.2 updated logic to search for non-core campaigns (e.g., P2P) | |
| 32 | - * @since 3.0.0 | |
| 33 | - */ | |
| 34 | 30 | public function __invoke(DonationForm $formV2, TransferOptions $options) |
| 35 | 31 | { |
| 36 | 32 | DB::transaction(function() use ($formV2, $options) { |
| 37 | 33 | |
| @@ -37,32 +33,8 @@ | ||
| 37 | 33 | |
| 38 | 34 | $v3FormId = (new GetMigratedFormId)($formV2->id); |
| 39 | 35 | TransferFormUrl::from($formV2->id)->to($v3FormId); |
| 40 | 36 | TransferDonations::from($formV2->id)->to($v3FormId); |
| 41 | - | |
| 42 | - // Promote upgraded form to default form | |
| 43 | - $campaignRepository = give(CampaignRepository::class); | |
| 44 | - if ($campaign = $campaignRepository->getByFormId($formV2->id)) { | |
| 45 | - $defaultForm = $campaign->defaultForm(); | |
| 46 | - | |
| 47 | - if ($defaultForm->id === $formV2->id) { | |
| 48 | - $campaignRepository->updateDefaultCampaignForm($campaign, $v3FormId); | |
| 49 | - } | |
| 50 | - } else { | |
| 51 | - // Fallback: Check for non-core campaigns (e.g., P2P) linked via give_campaigns.form_id | |
| 52 | - $campaignData = DB::table('give_campaigns') | |
| 53 | - ->where('form_id', $formV2->id) | |
| 54 | - ->where('campaign_type', CampaignType::CORE, '!=') | |
| 55 | - ->get(); | |
| 56 | - | |
| 57 | - if ($campaignData) { | |
| 58 | - DB::table('give_campaigns') | |
| 59 | - ->where('id', $campaignData->id) | |
| 60 | - ->update([ | |
| 61 | - 'form_id' => $v3FormId, | |
| 62 | - ]); | |
| 63 | - } | |
| 64 | - } | |
| 65 | 37 | |
| 66 | 38 | if($options->shouldDelete()) { |
| 67 | 39 | wp_trash_post($formV2->id); |
| 68 | 40 | } |