Skip to content

Commit

Permalink
refactor: Replace enum status with raw strings
Browse files Browse the repository at this point in the history
  • Loading branch information
kjohnson committed Sep 9, 2024
1 parent 929d707 commit bde30e0
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/Campaigns/Migrations/MigrateFormsToCampaignForms.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function createParentCampaignForDonationForm($formData): void

$campaignId = DB::table('give_campaigns')
->insert([
'campaign_type' => CampaignType::CORE()->getValue(),
'campaign_type' => 'core',
'campaign_title' => $formTitle,
'status' => $this->mapFormToCampaignStatus($formStatus),
'short_desc' => $formSettings->formExcerpt,
Expand Down Expand Up @@ -124,22 +124,22 @@ public function mapFormToCampaignStatus(string $status): string
{
switch ($status) {

case DonationFormStatus::PENDING():
return CampaignStatus::PENDING()->getValue();
case 'pending':
return 'pending';

case DonationFormStatus::DRAFT():
return CampaignStatus::DRAFT()->getValue();
case 'draft':
return 'draft';

case DonationFormStatus::TRASH():
return CampaignStatus::INACTIVE()->getValue();
case 'trash':
return 'inactive';

case DonationFormStatus::PUBLISHED():
case DonationFormStatus::UPGRADED(): // TODO: How do we handle upgraded, non-upgraded forms?
case DonationFormStatus::PRIVATE(): // TODO: How do we handle Private forms?
return CampaignStatus::ACTIVE()->getValue();
case 'publish':
case 'private':
case 'upgraded':
return 'active';

default: // TODO: How do we handle an unknown form status?
return CampaignStatus::INACTIVE()->getValue();
return 'inactive';
}
}
}

0 comments on commit bde30e0

Please sign in to comment.