PluginProbe
The Innovative Form Builder – IvyForms / 1.5
The Innovative Form Builder – IvyForms v1.5
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / backend / src / Common / Helpers / Import / WsFormGdprFieldMapper.php

WsFormGdprFieldMapper.php in The Innovative Form Builder – IvyForms 1.5, at backend/src/Common/Helpers/Import/WsFormGdprFieldMapper.php

46 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace IvyForms\Common\Helpers\Import;
4
5 /**
6 * Detect WS Form consent checkboxes and map them to IvyForms GDPR fields.
7 *
8 * WS Form has no GDPR field type; consent is modelled as a checkbox with a
9 * single required option. IvyForms has a dedicated GDPR field, so that shape
10 * is remapped during import.
11 */
12 class WsFormGdprFieldMapper
13 {
14 /**
15 * Whether a mapped checkbox should become an IvyForms GDPR field.
16 *
17 * @param string $wsType
18 * @param array<string, mixed> $meta
19 * @return bool
20 */
21 public static function matches(string $wsType, array $meta): bool
22 {
23 return $wsType === 'checkbox'
24 && WsFormOptionsExtractor::extractConsentText($meta) !== null;
25 }
26
27 /**
28 * Apply GDPR-specific properties to an already-built field payload.
29 *
30 * @param array<string, mixed> $field
31 * @param array<string, mixed> $meta
32 * @return void
33 */
34 public static function apply(array &$field, array $meta): void
35 {
36 $agreementText = WsFormOptionsExtractor::extractConsentText($meta);
37 $field['type'] = 'gdpr';
38 $field['required'] = true;
39 $field['defaultValue'] = '';
40 $field['agreementText'] = $agreementText !== null ? $agreementText : '';
41 // WS Form hides the field label for consent checkboxes (label_render off);
42 // IvyForms shows label and agreement text separately.
43 $field['hideLabel'] = false;
44 }
45 }
46