EditFieldsForm.php
4 weeks ago
FormAbstract.php
4 weeks ago
FormIntegration.php
4 weeks ago
FormInterface.php
4 weeks ago
SettingsPageForm.php
4 weeks ago
FormIntegration.php
70 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPDesk\FCF\Free\Settings\Form; |
| 4 | |
| 5 | /** |
| 6 | * Initializes integration for form. |
| 7 | */ |
| 8 | class FormIntegration { |
| 9 | |
| 10 | /** |
| 11 | * Class object for field type. |
| 12 | * |
| 13 | * @var FormInterface |
| 14 | */ |
| 15 | private $form_object; |
| 16 | |
| 17 | /** |
| 18 | * Class constructor. |
| 19 | * |
| 20 | * @param FormInterface $form_object Class object of field type. |
| 21 | */ |
| 22 | public function __construct( FormInterface $form_object ) { |
| 23 | $this->form_object = $form_object; |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * {@inheritdoc} |
| 28 | */ |
| 29 | public function hooks() { |
| 30 | add_filter( |
| 31 | 'flexible_checkout_fields/form_data_' . $this->form_object->get_form_type(), |
| 32 | [ $this, 'get_form_data' ], |
| 33 | 10, |
| 34 | 2 |
| 35 | ); |
| 36 | add_filter( |
| 37 | 'flexible_checkout_fields/form_fields_' . $this->form_object->get_form_type(), |
| 38 | [ $this, 'get_form_fields' ], |
| 39 | 10, |
| 40 | 2 |
| 41 | ); |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Returns updated settings for form. |
| 46 | * |
| 47 | * @param array $form_data Default settings of form. |
| 48 | * @param string $form_key Key of form. |
| 49 | * |
| 50 | * @return array Settings of form. |
| 51 | * @internal |
| 52 | */ |
| 53 | public function get_form_data( array $form_data, string $form_key = '' ): array { |
| 54 | return $this->form_object->get_form_data( $form_data, $form_key ); |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Returns fields of settings for form. |
| 59 | * |
| 60 | * @param array $form_fields Default fields of form. |
| 61 | * @param string $form_key Key of form. |
| 62 | * |
| 63 | * @return array Fields of form. |
| 64 | * @internal |
| 65 | */ |
| 66 | public function get_form_fields( array $form_fields, string $form_key = '' ): array { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter |
| 67 | return $this->form_object->get_options_list(); |
| 68 | } |
| 69 | } |
| 70 |