ClassicTemplateSettings.php
2 years ago
LegacyTemplateSettings.php
2 years ago
SequoiaTemplateSettings.php
2 years ago
LegacyTemplateSettings.php
58 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\FormMigration\Steps\FormTemplate; |
| 4 | |
| 5 | use Give\FormMigration\Concerns\Blocks\BlockFactory;; |
| 6 | use Give\FormMigration\Contracts\FormMigrationStep; |
| 7 | |
| 8 | class LegacyTemplateSettings extends FormMigrationStep |
| 9 | { |
| 10 | public function canHandle(): bool |
| 11 | { |
| 12 | return 'legacy' === $this->formV2->getFormTemplate(); |
| 13 | } |
| 14 | |
| 15 | public function process() |
| 16 | { |
| 17 | [ |
| 18 | 'display_settings' => $displaySettings, |
| 19 | ] = $this->formV2->getFormTemplateSettings(); |
| 20 | |
| 21 | $this->displaySettings($displaySettings); |
| 22 | } |
| 23 | |
| 24 | protected function displaySettings($settings) |
| 25 | { |
| 26 | [ |
| 27 | 'display_style' => $displayStyle, // 'buttons', |
| 28 | 'payment_display' => $paymentDisplay, // 'onpage', |
| 29 | 'reveal_label' => $revealLabel, // '', |
| 30 | 'checkout_label' => $checkoutLabel, // 'Donate Now', |
| 31 | 'form_floating_labels' => $floatingLabels, // 'global', |
| 32 | 'display_content' => $displayContent, // 'disabled', |
| 33 | 'content_placement' => $contentPlacement, // 'give_pre_form', |
| 34 | 'form_content' => $formContent, // '', |
| 35 | ] = $settings; |
| 36 | |
| 37 | // @note `display_style`` is not supported in v3 forms (defers to the Form Design). |
| 38 | |
| 39 | // @note `payment_display`, `reveal_label` are not supported in v3 forms (defers to the Form Design). |
| 40 | |
| 41 | // @note `checkout_label` is not supported in v3 forms (defers to the Form Design). |
| 42 | |
| 43 | // @note `form_floating_labels` is not supported in v3 forms (defers to the Form Design). |
| 44 | |
| 45 | if(give_is_setting_enabled($displayContent)) { |
| 46 | |
| 47 | $formContentSection = BlockFactory::section(); |
| 48 | $formContentSection->innerBlocks->append(BlockFactory::paragraph($formContent)); |
| 49 | |
| 50 | if('give_pre_form' === $contentPlacement) { |
| 51 | $this->fieldBlocks->prepend($formContentSection); |
| 52 | } else { |
| 53 | $this->fieldBlocks->append($formContentSection); |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | } |
| 58 |