DonationFormFactory.php
48 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\DonationForms\Factories; |
| 4 | |
| 5 | use Give\DonationForms\Properties\FormSettings; |
| 6 | use Give\DonationForms\ValueObjects\DonationFormStatus; |
| 7 | use Give\DonationForms\ValueObjects\GoalSource; |
| 8 | use Give\DonationForms\ValueObjects\GoalType; |
| 9 | use Give\Framework\Blocks\BlockCollection; |
| 10 | use Give\Framework\Models\Factories\ModelFactory; |
| 11 | |
| 12 | class DonationFormFactory extends ModelFactory |
| 13 | { |
| 14 | /** |
| 15 | * @since 4.1.0 added goalSource |
| 16 | * @since 3.0.0 |
| 17 | */ |
| 18 | public function definition(): array |
| 19 | { |
| 20 | $blocksJson = file_get_contents( |
| 21 | GIVE_PLUGIN_DIR . 'src/FormBuilder/resources/js/form-builder/src/blocks.json' |
| 22 | ); |
| 23 | |
| 24 | return [ |
| 25 | 'title' => __('GiveWP Donation Form', 'give'), |
| 26 | 'status' => DonationFormStatus::PUBLISHED(), |
| 27 | 'settings' => FormSettings::fromArray([ |
| 28 | 'enableDonationGoal' => false, |
| 29 | 'goalAmount' => $this->faker->numberBetween(100, 5000), |
| 30 | 'enableAutoClose' => false, |
| 31 | 'registration' => 'none', |
| 32 | 'goalType' => GoalType::AMOUNT(), |
| 33 | 'goalSource' => GoalSource::FORM(), |
| 34 | 'designId' => 'classic', |
| 35 | 'showHeading' => true, |
| 36 | 'showDescription' => true, |
| 37 | 'heading' => __('Support Our Cause', 'give'), |
| 38 | 'description' => __( |
| 39 | 'Help our organization by donating today! All donations go directly to making a difference for our cause.', |
| 40 | 'give' |
| 41 | ), |
| 42 | 'goalAchievedMessage' => __('Thank you to all our donors, we have met our fundraising goal.', 'give'), |
| 43 | ]), |
| 44 | 'blocks' => BlockCollection::fromJson($blocksJson), |
| 45 | ]; |
| 46 | } |
| 47 | } |
| 48 |