Completed
Branch FET/reg-form-builder/main (0f11d8)
by
unknown
02:56 queued 17s
created
core/services/form/meta/Attributes.php 2 patches
Indentation   +180 added lines, -180 removed lines patch added patch discarded remove patch
@@ -17,184 +17,184 @@
 block discarded – undo
17 17
 class Attributes implements JsonableInterface
18 18
 {
19 19
 
20
-    /**
21
-     * @var JsonDataHandler
22
-     */
23
-    private $json_data_handler;
24
-
25
-    /**
26
-     * @var InputTypes
27
-     */
28
-    private $input_types;
29
-
30
-    /**
31
-     * @var array
32
-     */
33
-    private $attributes = [];
34
-
35
-    /**
36
-     * @var array
37
-     */
38
-    private $attribute_types = [
39
-        'accept'          => 'string',
40
-        'accesskey'       => 'string',
41
-        'alt'             => 'string',
42
-        'autocomplete'    => 'bool',
43
-        'autofocus'       => 'bool',
44
-        'checked'         => 'bool',
45
-        // Custom HTML classes to be applied to the form input's container
46
-        'class'           => 'string',
47
-        'contenteditable' => 'bool',
48
-        'dir'             => 'string',
49
-        'disabled'        => 'bool',
50
-        'height'          => 'string',
51
-        'hidden'          => 'bool',
52
-        'id'              => 'string',
53
-        'list'            => 'string',
54
-        // Maximum numeric value allowed for form input answer.
55
-        'max'             => 'int',
56
-        // Maximum characters allowed for form input answer.
57
-        'maxlength'       => 'int',
58
-        // Minimum numeric value allowed for form input answer.
59
-        'min'             => 'int',
60
-        'multiple'        => 'bool',
61
-        'name'            => 'string',
62
-        'pattern'         => 'string',
63
-        // Example text displayed within an input to assist users with completing the form.
64
-        'placeholder'     => 'string',
65
-        'readonly'        => 'bool',
66
-        'size'            => 'int',
67
-        'spellcheck'      => 'bool',
68
-        'step'            => 'float',
69
-        'style'           => 'string',
70
-        'tabindex'        => 'int',
71
-        'title'           => 'string',
72
-        'translate'       => 'bool',
73
-        // Form input type. Values correspond to the Input::TYPE_* constants.
74
-        'type'            => 'string',
75
-        'value'           => 'string',
76
-        'width'           => 'string',
77
-    ];
78
-
79
-
80
-    /**
81
-     * Attributes constructor.
82
-     *
83
-     * @param JsonDataHandler $json_data_handler
84
-     * @param InputTypes      $element_types
85
-     * @param array           $attributes
86
-     */
87
-    public function __construct(JsonDataHandler $json_data_handler, array $attributes, InputTypes $element_types)
88
-    {
89
-        $this->json_data_handler = $json_data_handler;
90
-        $this->input_types       = $element_types;
91
-        $this->setAttributes($attributes);
92
-    }
93
-
94
-
95
-    /**
96
-     * @param string $json
97
-     * @return Attributes
98
-     */
99
-    public static function fromJson(string $json): Attributes
100
-    {
101
-        $json_data_handler = new JsonDataHandler();
102
-        $json_data_handler->configure(JsonDataHandler::DATA_TYPE_ARRAY);
103
-        $attributes = $json_data_handler->decodeJson($json);
104
-        /** @var InputTypes */
105
-        $element_types = LoaderFactory::getShared('EventEspresso\core\services\form\meta\InputTypes');
106
-        return LoaderFactory::getNew(Attributes::class, [ $json_data_handler, $attributes, $element_types ]);
107
-    }
108
-
109
-
110
-    /**
111
-     * @return array
112
-     */
113
-    public function toArray(): array
114
-    {
115
-        return $this->attributes();
116
-    }
117
-
118
-
119
-    /**
120
-     * @return string
121
-     */
122
-    public function toJson(): string
123
-    {
124
-        return $this->json_data_handler->encodeData($this->attributes());
125
-    }
126
-
127
-
128
-    /**
129
-     * @param string                $attribute
130
-     * @param bool|float|int|string $value
131
-     * @return bool|float|int|string
132
-     */
133
-    private function sanitize(string $attribute, $value)
134
-    {
135
-        if ($attribute === 'type') {
136
-            $valid_types = $this->input_types->validTypeOptions();
137
-            return in_array($value, $valid_types, true) ?: Text::TYPE_TEXT;
138
-        }
139
-        $type = $this->attribute_types[ $attribute ] ?? 'string';
140
-        switch ($type) {
141
-            case 'bool':
142
-                return filter_var($value, FILTER_VALIDATE_BOOLEAN);
143
-            case 'int':
144
-                return filter_var($value, FILTER_SANITIZE_NUMBER_INT);
145
-            case 'float':
146
-                return filter_var($value, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
147
-            case 'string':
148
-            default:
149
-                return filter_var(
150
-                    $value,
151
-                    FILTER_SANITIZE_STRING,
152
-                    FILTER_FLAG_ENCODE_LOW | FILTER_FLAG_ENCODE_HIGH | FILTER_FLAG_ENCODE_AMP
153
-                );
154
-        }
155
-    }
156
-
157
-
158
-    /**
159
-     * Custom HTML classes to be applied to this form input's help text.
160
-     * returns a concatenated string unless $as_array is set to true
161
-     *
162
-     * @return array
163
-     */
164
-    public function attributes(): array
165
-    {
166
-        return $this->attributes;
167
-    }
168
-
169
-
170
-    /**
171
-     * @param string                $attribute
172
-     * @param bool|float|int|string $value
173
-     */
174
-    public function addAttribute(string $attribute, $value): void
175
-    {
176
-        if (array_key_exists($attribute, $this->attribute_types)) {
177
-            $this->attributes[ $attribute ] = $this->sanitize($attribute, $value);
178
-        }
179
-    }
180
-
181
-
182
-    /**
183
-     * @param string $attribute
184
-     */
185
-    public function removeAttribute(string $attribute): void
186
-    {
187
-        unset($this->attributes[ $attribute ]);
188
-    }
189
-
190
-
191
-    /**
192
-     * @param array $attributes array where keys are the attribute name and values are the attribute's value
193
-     */
194
-    public function setAttributes(array $attributes): void
195
-    {
196
-        foreach ($attributes as $attribute => $value) {
197
-            $this->addAttribute($attribute, $value);
198
-        }
199
-    }
20
+	/**
21
+	 * @var JsonDataHandler
22
+	 */
23
+	private $json_data_handler;
24
+
25
+	/**
26
+	 * @var InputTypes
27
+	 */
28
+	private $input_types;
29
+
30
+	/**
31
+	 * @var array
32
+	 */
33
+	private $attributes = [];
34
+
35
+	/**
36
+	 * @var array
37
+	 */
38
+	private $attribute_types = [
39
+		'accept'          => 'string',
40
+		'accesskey'       => 'string',
41
+		'alt'             => 'string',
42
+		'autocomplete'    => 'bool',
43
+		'autofocus'       => 'bool',
44
+		'checked'         => 'bool',
45
+		// Custom HTML classes to be applied to the form input's container
46
+		'class'           => 'string',
47
+		'contenteditable' => 'bool',
48
+		'dir'             => 'string',
49
+		'disabled'        => 'bool',
50
+		'height'          => 'string',
51
+		'hidden'          => 'bool',
52
+		'id'              => 'string',
53
+		'list'            => 'string',
54
+		// Maximum numeric value allowed for form input answer.
55
+		'max'             => 'int',
56
+		// Maximum characters allowed for form input answer.
57
+		'maxlength'       => 'int',
58
+		// Minimum numeric value allowed for form input answer.
59
+		'min'             => 'int',
60
+		'multiple'        => 'bool',
61
+		'name'            => 'string',
62
+		'pattern'         => 'string',
63
+		// Example text displayed within an input to assist users with completing the form.
64
+		'placeholder'     => 'string',
65
+		'readonly'        => 'bool',
66
+		'size'            => 'int',
67
+		'spellcheck'      => 'bool',
68
+		'step'            => 'float',
69
+		'style'           => 'string',
70
+		'tabindex'        => 'int',
71
+		'title'           => 'string',
72
+		'translate'       => 'bool',
73
+		// Form input type. Values correspond to the Input::TYPE_* constants.
74
+		'type'            => 'string',
75
+		'value'           => 'string',
76
+		'width'           => 'string',
77
+	];
78
+
79
+
80
+	/**
81
+	 * Attributes constructor.
82
+	 *
83
+	 * @param JsonDataHandler $json_data_handler
84
+	 * @param InputTypes      $element_types
85
+	 * @param array           $attributes
86
+	 */
87
+	public function __construct(JsonDataHandler $json_data_handler, array $attributes, InputTypes $element_types)
88
+	{
89
+		$this->json_data_handler = $json_data_handler;
90
+		$this->input_types       = $element_types;
91
+		$this->setAttributes($attributes);
92
+	}
93
+
94
+
95
+	/**
96
+	 * @param string $json
97
+	 * @return Attributes
98
+	 */
99
+	public static function fromJson(string $json): Attributes
100
+	{
101
+		$json_data_handler = new JsonDataHandler();
102
+		$json_data_handler->configure(JsonDataHandler::DATA_TYPE_ARRAY);
103
+		$attributes = $json_data_handler->decodeJson($json);
104
+		/** @var InputTypes */
105
+		$element_types = LoaderFactory::getShared('EventEspresso\core\services\form\meta\InputTypes');
106
+		return LoaderFactory::getNew(Attributes::class, [ $json_data_handler, $attributes, $element_types ]);
107
+	}
108
+
109
+
110
+	/**
111
+	 * @return array
112
+	 */
113
+	public function toArray(): array
114
+	{
115
+		return $this->attributes();
116
+	}
117
+
118
+
119
+	/**
120
+	 * @return string
121
+	 */
122
+	public function toJson(): string
123
+	{
124
+		return $this->json_data_handler->encodeData($this->attributes());
125
+	}
126
+
127
+
128
+	/**
129
+	 * @param string                $attribute
130
+	 * @param bool|float|int|string $value
131
+	 * @return bool|float|int|string
132
+	 */
133
+	private function sanitize(string $attribute, $value)
134
+	{
135
+		if ($attribute === 'type') {
136
+			$valid_types = $this->input_types->validTypeOptions();
137
+			return in_array($value, $valid_types, true) ?: Text::TYPE_TEXT;
138
+		}
139
+		$type = $this->attribute_types[ $attribute ] ?? 'string';
140
+		switch ($type) {
141
+			case 'bool':
142
+				return filter_var($value, FILTER_VALIDATE_BOOLEAN);
143
+			case 'int':
144
+				return filter_var($value, FILTER_SANITIZE_NUMBER_INT);
145
+			case 'float':
146
+				return filter_var($value, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
147
+			case 'string':
148
+			default:
149
+				return filter_var(
150
+					$value,
151
+					FILTER_SANITIZE_STRING,
152
+					FILTER_FLAG_ENCODE_LOW | FILTER_FLAG_ENCODE_HIGH | FILTER_FLAG_ENCODE_AMP
153
+				);
154
+		}
155
+	}
156
+
157
+
158
+	/**
159
+	 * Custom HTML classes to be applied to this form input's help text.
160
+	 * returns a concatenated string unless $as_array is set to true
161
+	 *
162
+	 * @return array
163
+	 */
164
+	public function attributes(): array
165
+	{
166
+		return $this->attributes;
167
+	}
168
+
169
+
170
+	/**
171
+	 * @param string                $attribute
172
+	 * @param bool|float|int|string $value
173
+	 */
174
+	public function addAttribute(string $attribute, $value): void
175
+	{
176
+		if (array_key_exists($attribute, $this->attribute_types)) {
177
+			$this->attributes[ $attribute ] = $this->sanitize($attribute, $value);
178
+		}
179
+	}
180
+
181
+
182
+	/**
183
+	 * @param string $attribute
184
+	 */
185
+	public function removeAttribute(string $attribute): void
186
+	{
187
+		unset($this->attributes[ $attribute ]);
188
+	}
189
+
190
+
191
+	/**
192
+	 * @param array $attributes array where keys are the attribute name and values are the attribute's value
193
+	 */
194
+	public function setAttributes(array $attributes): void
195
+	{
196
+		foreach ($attributes as $attribute => $value) {
197
+			$this->addAttribute($attribute, $value);
198
+		}
199
+	}
200 200
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
         $attributes = $json_data_handler->decodeJson($json);
104 104
         /** @var InputTypes */
105 105
         $element_types = LoaderFactory::getShared('EventEspresso\core\services\form\meta\InputTypes');
106
-        return LoaderFactory::getNew(Attributes::class, [ $json_data_handler, $attributes, $element_types ]);
106
+        return LoaderFactory::getNew(Attributes::class, [$json_data_handler, $attributes, $element_types]);
107 107
     }
108 108
 
109 109
 
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
             $valid_types = $this->input_types->validTypeOptions();
137 137
             return in_array($value, $valid_types, true) ?: Text::TYPE_TEXT;
138 138
         }
139
-        $type = $this->attribute_types[ $attribute ] ?? 'string';
139
+        $type = $this->attribute_types[$attribute] ?? 'string';
140 140
         switch ($type) {
141 141
             case 'bool':
142 142
                 return filter_var($value, FILTER_VALIDATE_BOOLEAN);
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
     public function addAttribute(string $attribute, $value): void
175 175
     {
176 176
         if (array_key_exists($attribute, $this->attribute_types)) {
177
-            $this->attributes[ $attribute ] = $this->sanitize($attribute, $value);
177
+            $this->attributes[$attribute] = $this->sanitize($attribute, $value);
178 178
         }
179 179
     }
180 180
 
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
      */
185 185
     public function removeAttribute(string $attribute): void
186 186
     {
187
-        unset($this->attributes[ $attribute ]);
187
+        unset($this->attributes[$attribute]);
188 188
     }
189 189
 
190 190
 
Please login to merge, or discard this patch.
core/services/form/meta/FormStatus.php 2 patches
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -15,74 +15,74 @@
 block discarded – undo
15 15
 class FormStatus
16 16
 {
17 17
 
18
-    /**
19
-     * indicates that element is not archived or trashed
20
-     */
21
-    public const ACTIVE = 'active';
18
+	/**
19
+	 * indicates that element is not archived or trashed
20
+	 */
21
+	public const ACTIVE = 'active';
22 22
 
23
-    /**
24
-     * indicates that element is archived and should no longer be displayed on public forms
25
-     * but may still be required due to existing answers when form was completed prior to input being archived
26
-     */
27
-    public const ARCHIVED = 'archived';
23
+	/**
24
+	 * indicates that element is archived and should no longer be displayed on public forms
25
+	 * but may still be required due to existing answers when form was completed prior to input being archived
26
+	 */
27
+	public const ARCHIVED = 'archived';
28 28
 
29
-    /**
30
-     * indicates that element should be automatically added to newly created forms
31
-     */
32
-    public const DEFAULT = 'default';
29
+	/**
30
+	 * indicates that element should be automatically added to newly created forms
31
+	 */
32
+	public const DEFAULT = 'default';
33 33
 
34
-    /**
35
-     * indicates that a copy of the form section will be saved for use in other events but not loaded by default
36
-     */
37
-    public const SHARED = 'shared';
34
+	/**
35
+	 * indicates that a copy of the form section will be saved for use in other events but not loaded by default
36
+	 */
37
+	public const SHARED = 'shared';
38 38
 
39
-    /**
40
-     * indicates that element is no longer needed, has no existing answers, and can be moved to the trash
41
-     */
42
-    public const TRASHED = 'trashed';
39
+	/**
40
+	 * indicates that element is no longer needed, has no existing answers, and can be moved to the trash
41
+	 */
42
+	public const TRASHED = 'trashed';
43 43
 
44
-    /**
45
-     * @var array
46
-     */
47
-    private $valid_status_options;
44
+	/**
45
+	 * @var array
46
+	 */
47
+	private $valid_status_options;
48 48
 
49 49
 
50
-    public function __construct()
51
-    {
52
-        $this->valid_status_options = apply_filters(
53
-            'FHEE__EventEspresso_core_services_form_meta_FormStatus__valid_status_options',
54
-            [
55
-                FormStatus::ACTIVE   => esc_html__('Active', 'event_espresso'),
56
-                FormStatus::ARCHIVED => esc_html__('Archived', 'event_espresso'),
57
-                FormStatus::DEFAULT  => esc_html__('Default', 'event_espresso'),
58
-                FormStatus::SHARED   => esc_html__('Shared', 'event_espresso'),
59
-                FormStatus::TRASHED  => esc_html__('Trashed', 'event_espresso'),
60
-            ]
61
-        );
62
-    }
50
+	public function __construct()
51
+	{
52
+		$this->valid_status_options = apply_filters(
53
+			'FHEE__EventEspresso_core_services_form_meta_FormStatus__valid_status_options',
54
+			[
55
+				FormStatus::ACTIVE   => esc_html__('Active', 'event_espresso'),
56
+				FormStatus::ARCHIVED => esc_html__('Archived', 'event_espresso'),
57
+				FormStatus::DEFAULT  => esc_html__('Default', 'event_espresso'),
58
+				FormStatus::SHARED   => esc_html__('Shared', 'event_espresso'),
59
+				FormStatus::TRASHED  => esc_html__('Trashed', 'event_espresso'),
60
+			]
61
+		);
62
+	}
63 63
 
64 64
 
65
-    /**
66
-     * @return array
67
-     */
68
-    public function getFormStatusValues(): array
69
-    {
70
-        $values = [];
71
-        foreach ($this->valid_status_options as $value => $description) {
72
-            $values[ GQLUtils::formatEnumKey($value) ] = compact('value', 'description');
73
-        }
74
-        return $values;
75
-    }
65
+	/**
66
+	 * @return array
67
+	 */
68
+	public function getFormStatusValues(): array
69
+	{
70
+		$values = [];
71
+		foreach ($this->valid_status_options as $value => $description) {
72
+			$values[ GQLUtils::formatEnumKey($value) ] = compact('value', 'description');
73
+		}
74
+		return $values;
75
+	}
76 76
 
77 77
 
78
-    /**
79
-     * @param bool $constants_only
80
-     * @return array
81
-     */
82
-    public function validStatusOptions(bool $constants_only = false): array
83
-    {
84
-        return $constants_only
85
-            ? array_keys($this->valid_status_options)
86
-            : $this->valid_status_options;
87
-    }
78
+	/**
79
+	 * @param bool $constants_only
80
+	 * @return array
81
+	 */
82
+	public function validStatusOptions(bool $constants_only = false): array
83
+	{
84
+		return $constants_only
85
+			? array_keys($this->valid_status_options)
86
+			: $this->valid_status_options;
87
+	}
88 88
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@
 block discarded – undo
69 69
     {
70 70
         $values = [];
71 71
         foreach ($this->valid_status_options as $value => $description) {
72
-            $values[ GQLUtils::formatEnumKey($value) ] = compact('value', 'description');
72
+            $values[GQLUtils::formatEnumKey($value)] = compact('value', 'description');
73 73
         }
74 74
         return $values;
75 75
     }
Please login to merge, or discard this patch.
core/services/form/meta/InputTypes.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@
 block discarded – undo
116 116
     {
117 117
         $values = [];
118 118
         foreach ($this->valid_type_options as $value => $description) {
119
-            $values[ GQLUtils::formatEnumKey($value) ] = compact('value', 'description');
119
+            $values[GQLUtils::formatEnumKey($value)] = compact('value', 'description');
120 120
         }
121 121
         return $values;
122 122
     }
Please login to merge, or discard this patch.
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -22,124 +22,124 @@
 block discarded – undo
22 22
  */
23 23
 class InputTypes
24 24
 {
25
-    /**
26
-     * @var Block
27
-     */
28
-    private $block;
29
-
30
-    /**
31
-     * @var Button
32
-     */
33
-    private $button;
34
-
35
-    /**
36
-     * @var DateTime
37
-     */
38
-    private $datetime;
39
-
40
-    /**
41
-     * @var Input
42
-     */
43
-    private $input;
44
-
45
-    /**
46
-     * @var Number
47
-     */
48
-    private $number;
49
-
50
-    /**
51
-     * @var Phone
52
-     */
53
-    private $phone;
54
-
55
-    /**
56
-     * @var Select
57
-     */
58
-    private $select;
59
-
60
-    /**
61
-     * @var Text
62
-     */
63
-    private $text;
64
-
65
-    /**
66
-     * @var array
67
-     */
68
-    private $valid_type_options;
69
-
70
-
71
-    /**
72
-     * InputTypes constructor.
73
-     *
74
-     * @param Block   $block
75
-     * @param Button   $button
76
-     * @param DateTime $datetime
77
-     * @param Input    $input
78
-     * @param Number   $number
79
-     * @param Phone    $phone
80
-     * @param Select   $select
81
-     * @param Text     $text
82
-     */
83
-    public function __construct(
84
-        Block $block,
85
-        Button $button,
86
-        DateTime $datetime,
87
-        Input $input,
88
-        Number $number,
89
-        Phone $phone,
90
-        Select $select,
91
-        Text $text
92
-    ) {
93
-        $this->block    = $block;
94
-        $this->button   = $button;
95
-        $this->datetime = $datetime;
96
-        $this->input    = $input;
97
-        $this->number   = $number;
98
-        $this->phone    = $phone;
99
-        $this->select   = $select;
100
-        $this->text     = $text;
101
-        $this->assembleValidTypeOptions();
102
-    }
103
-
104
-
105
-    private function assembleValidTypeOptions()
106
-    {
107
-        $block    = $this->block->validTypeOptions();
108
-        $button   = $this->button->validTypeOptions();
109
-        $datetime = $this->datetime->validTypeOptions();
110
-        $input    = $this->input->validTypeOptions();
111
-        $number   = $this->number->validTypeOptions();
112
-        $phone    = $this->phone->validTypeOptions();
113
-        $select   = $this->select->validTypeOptions();
114
-        $text     = $this->text->validTypeOptions();
115
-        $this->valid_type_options = apply_filters(
116
-            'FHEE__EventEspresso_core_services_form_meta_InputTypes__valid_type_options',
117
-            array_merge($block, $button, $datetime, $input, $number, $phone, $select, $text)
118
-        );
119
-    }
120
-
121
-
122
-    /**
123
-     * @return array
124
-     */
125
-    public function getInputTypesValues(): array
126
-    {
127
-        $values = [];
128
-        foreach ($this->valid_type_options as $value => $description) {
129
-            $values[ GQLUtils::formatEnumKey($value) ] = compact('value', 'description');
130
-        }
131
-        return $values;
132
-    }
133
-
134
-
135
-    /**
136
-     * @param bool $constants_only
137
-     * @return array
138
-     */
139
-    public function validTypeOptions(bool $constants_only = false): array
140
-    {
141
-        return $constants_only
142
-            ? array_keys($this->valid_type_options)
143
-            : $this->valid_type_options;
144
-    }
25
+	/**
26
+	 * @var Block
27
+	 */
28
+	private $block;
29
+
30
+	/**
31
+	 * @var Button
32
+	 */
33
+	private $button;
34
+
35
+	/**
36
+	 * @var DateTime
37
+	 */
38
+	private $datetime;
39
+
40
+	/**
41
+	 * @var Input
42
+	 */
43
+	private $input;
44
+
45
+	/**
46
+	 * @var Number
47
+	 */
48
+	private $number;
49
+
50
+	/**
51
+	 * @var Phone
52
+	 */
53
+	private $phone;
54
+
55
+	/**
56
+	 * @var Select
57
+	 */
58
+	private $select;
59
+
60
+	/**
61
+	 * @var Text
62
+	 */
63
+	private $text;
64
+
65
+	/**
66
+	 * @var array
67
+	 */
68
+	private $valid_type_options;
69
+
70
+
71
+	/**
72
+	 * InputTypes constructor.
73
+	 *
74
+	 * @param Block   $block
75
+	 * @param Button   $button
76
+	 * @param DateTime $datetime
77
+	 * @param Input    $input
78
+	 * @param Number   $number
79
+	 * @param Phone    $phone
80
+	 * @param Select   $select
81
+	 * @param Text     $text
82
+	 */
83
+	public function __construct(
84
+		Block $block,
85
+		Button $button,
86
+		DateTime $datetime,
87
+		Input $input,
88
+		Number $number,
89
+		Phone $phone,
90
+		Select $select,
91
+		Text $text
92
+	) {
93
+		$this->block    = $block;
94
+		$this->button   = $button;
95
+		$this->datetime = $datetime;
96
+		$this->input    = $input;
97
+		$this->number   = $number;
98
+		$this->phone    = $phone;
99
+		$this->select   = $select;
100
+		$this->text     = $text;
101
+		$this->assembleValidTypeOptions();
102
+	}
103
+
104
+
105
+	private function assembleValidTypeOptions()
106
+	{
107
+		$block    = $this->block->validTypeOptions();
108
+		$button   = $this->button->validTypeOptions();
109
+		$datetime = $this->datetime->validTypeOptions();
110
+		$input    = $this->input->validTypeOptions();
111
+		$number   = $this->number->validTypeOptions();
112
+		$phone    = $this->phone->validTypeOptions();
113
+		$select   = $this->select->validTypeOptions();
114
+		$text     = $this->text->validTypeOptions();
115
+		$this->valid_type_options = apply_filters(
116
+			'FHEE__EventEspresso_core_services_form_meta_InputTypes__valid_type_options',
117
+			array_merge($block, $button, $datetime, $input, $number, $phone, $select, $text)
118
+		);
119
+	}
120
+
121
+
122
+	/**
123
+	 * @return array
124
+	 */
125
+	public function getInputTypesValues(): array
126
+	{
127
+		$values = [];
128
+		foreach ($this->valid_type_options as $value => $description) {
129
+			$values[ GQLUtils::formatEnumKey($value) ] = compact('value', 'description');
130
+		}
131
+		return $values;
132
+	}
133
+
134
+
135
+	/**
136
+	 * @param bool $constants_only
137
+	 * @return array
138
+	 */
139
+	public function validTypeOptions(bool $constants_only = false): array
140
+	{
141
+		return $constants_only
142
+			? array_keys($this->valid_type_options)
143
+			: $this->valid_type_options;
144
+	}
145 145
 }
Please login to merge, or discard this patch.
core/services/form/meta/FormLabel.php 1 patch
Indentation   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -15,144 +15,144 @@
 block discarded – undo
15 15
 class FormLabel implements JsonableInterface
16 16
 {
17 17
 
18
-    /**
19
-     * @var JsonDataHandler
20
-     */
21
-    private $json_data_handler;
22
-
23
-    /**
24
-     * Input label displayed in the admin to help differentiate input from others
25
-     *
26
-     * @var string
27
-     */
28
-    private $adminLabel;
29
-
30
-    /**
31
-     * Input label displayed on public forms, ie: the actual question text.
32
-     *
33
-     * @var string
34
-     */
35
-    private $publicLabel;
36
-
37
-    /**
38
-     * @var bool
39
-     */
40
-    private $showLabel;
41
-
42
-
43
-    /**
44
-     * FormLabel constructor.
45
-     *
46
-     * @param JsonDataHandler $json_data_handler
47
-     * @param string          $adminLabel
48
-     * @param string          $publicLabel
49
-     * @param bool            $showLabel
50
-     */
51
-    public function __construct(
52
-        JsonDataHandler $json_data_handler,
53
-        string $adminLabel,
54
-        string $publicLabel,
55
-        bool $showLabel
56
-    ) {
57
-        $this->json_data_handler = $json_data_handler;
58
-        $this->setAdminLabel($adminLabel);
59
-        $this->setPublicLabel($publicLabel);
60
-        $this->setShowLabel($showLabel);
61
-    }
62
-
63
-
64
-    /**
65
-     * @param string $json
66
-     * @return FormLabel
67
-     */
68
-    public static function fromJson(string $json): FormLabel
69
-    {
70
-        $json_data_handler = new JsonDataHandler();
71
-        $json_data_handler->configure(JsonDataHandler::DATA_TYPE_OBJECT);
72
-        $data        = $json_data_handler->decodeJson($json);
73
-        $adminLabel  = $data->adminLabel ?? '';
74
-        $publicLabel = $data->publicLabel ?? '';
75
-        $showLabel   = $data->showLabel ?? false;
76
-        return new FormLabel($json_data_handler, $adminLabel, $publicLabel, $showLabel);
77
-    }
78
-
79
-
80
-    /**
81
-     * @return array
82
-     */
83
-    public function toArray(): array
84
-    {
85
-        return [
86
-            'adminLabel'  => $this->adminLabel,
87
-            'publicLabel' => $this->publicLabel,
88
-            'showLabel'   => $this->showLabel,
89
-        ];
90
-    }
91
-
92
-
93
-    /**
94
-     * @return string
95
-     */
96
-    public function toJson(): string
97
-    {
98
-        return $this->json_data_handler->encodeData($this->toArray());
99
-    }
100
-
101
-
102
-    /**
103
-     * Input label displayed in the admin to help differentiate input from others
104
-     *
105
-     * @return string
106
-     */
107
-    public function adminLabel(): string
108
-    {
109
-        return $this->adminLabel;
110
-    }
111
-
112
-
113
-    /**
114
-     * @param string $adminLabel
115
-     */
116
-    public function setAdminLabel(string $adminLabel): void
117
-    {
118
-        $this->adminLabel = sanitize_text_field($adminLabel);
119
-    }
120
-
121
-
122
-    /**
123
-     * Input label displayed on public forms, ie: the actual question text.
124
-     *
125
-     * @return string
126
-     */
127
-    public function publicLabel(): string
128
-    {
129
-        return $this->publicLabel;
130
-    }
131
-
132
-
133
-    /**
134
-     * @param string $publicLabel
135
-     */
136
-    public function setPublicLabel(string $publicLabel): void
137
-    {
138
-        $this->publicLabel = sanitize_text_field($publicLabel);
139
-    }
140
-
141
-
142
-    /**
143
-     * @return bool
144
-     */
145
-    public function showLabel(): bool
146
-    {
147
-        return $this->showLabel;
148
-    }
149
-
150
-
151
-    /**
152
-     * @param bool|int|string $showLabel
153
-     */
154
-    public function setShowLabel($showLabel): void
155
-    {
156
-        $this->showLabel = filter_var($showLabel, FILTER_VALIDATE_BOOLEAN);
157
-    }
18
+	/**
19
+	 * @var JsonDataHandler
20
+	 */
21
+	private $json_data_handler;
22
+
23
+	/**
24
+	 * Input label displayed in the admin to help differentiate input from others
25
+	 *
26
+	 * @var string
27
+	 */
28
+	private $adminLabel;
29
+
30
+	/**
31
+	 * Input label displayed on public forms, ie: the actual question text.
32
+	 *
33
+	 * @var string
34
+	 */
35
+	private $publicLabel;
36
+
37
+	/**
38
+	 * @var bool
39
+	 */
40
+	private $showLabel;
41
+
42
+
43
+	/**
44
+	 * FormLabel constructor.
45
+	 *
46
+	 * @param JsonDataHandler $json_data_handler
47
+	 * @param string          $adminLabel
48
+	 * @param string          $publicLabel
49
+	 * @param bool            $showLabel
50
+	 */
51
+	public function __construct(
52
+		JsonDataHandler $json_data_handler,
53
+		string $adminLabel,
54
+		string $publicLabel,
55
+		bool $showLabel
56
+	) {
57
+		$this->json_data_handler = $json_data_handler;
58
+		$this->setAdminLabel($adminLabel);
59
+		$this->setPublicLabel($publicLabel);
60
+		$this->setShowLabel($showLabel);
61
+	}
62
+
63
+
64
+	/**
65
+	 * @param string $json
66
+	 * @return FormLabel
67
+	 */
68
+	public static function fromJson(string $json): FormLabel
69
+	{
70
+		$json_data_handler = new JsonDataHandler();
71
+		$json_data_handler->configure(JsonDataHandler::DATA_TYPE_OBJECT);
72
+		$data        = $json_data_handler->decodeJson($json);
73
+		$adminLabel  = $data->adminLabel ?? '';
74
+		$publicLabel = $data->publicLabel ?? '';
75
+		$showLabel   = $data->showLabel ?? false;
76
+		return new FormLabel($json_data_handler, $adminLabel, $publicLabel, $showLabel);
77
+	}
78
+
79
+
80
+	/**
81
+	 * @return array
82
+	 */
83
+	public function toArray(): array
84
+	{
85
+		return [
86
+			'adminLabel'  => $this->adminLabel,
87
+			'publicLabel' => $this->publicLabel,
88
+			'showLabel'   => $this->showLabel,
89
+		];
90
+	}
91
+
92
+
93
+	/**
94
+	 * @return string
95
+	 */
96
+	public function toJson(): string
97
+	{
98
+		return $this->json_data_handler->encodeData($this->toArray());
99
+	}
100
+
101
+
102
+	/**
103
+	 * Input label displayed in the admin to help differentiate input from others
104
+	 *
105
+	 * @return string
106
+	 */
107
+	public function adminLabel(): string
108
+	{
109
+		return $this->adminLabel;
110
+	}
111
+
112
+
113
+	/**
114
+	 * @param string $adminLabel
115
+	 */
116
+	public function setAdminLabel(string $adminLabel): void
117
+	{
118
+		$this->adminLabel = sanitize_text_field($adminLabel);
119
+	}
120
+
121
+
122
+	/**
123
+	 * Input label displayed on public forms, ie: the actual question text.
124
+	 *
125
+	 * @return string
126
+	 */
127
+	public function publicLabel(): string
128
+	{
129
+		return $this->publicLabel;
130
+	}
131
+
132
+
133
+	/**
134
+	 * @param string $publicLabel
135
+	 */
136
+	public function setPublicLabel(string $publicLabel): void
137
+	{
138
+		$this->publicLabel = sanitize_text_field($publicLabel);
139
+	}
140
+
141
+
142
+	/**
143
+	 * @return bool
144
+	 */
145
+	public function showLabel(): bool
146
+	{
147
+		return $this->showLabel;
148
+	}
149
+
150
+
151
+	/**
152
+	 * @param bool|int|string $showLabel
153
+	 */
154
+	public function setShowLabel($showLabel): void
155
+	{
156
+		$this->showLabel = filter_var($showLabel, FILTER_VALIDATE_BOOLEAN);
157
+	}
158 158
 }
Please login to merge, or discard this patch.
core/services/form/meta/Required.php 1 patch
Indentation   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -15,110 +15,110 @@
 block discarded – undo
15 15
 class Required implements JsonableInterface
16 16
 {
17 17
 
18
-    /**
19
-     * @var JsonDataHandler
20
-     */
21
-    private $json_data_handler;
22
-
23
-    /** Whether or not the input must be supplied with a value in order to complete the form.
24
-     *
25
-     * @var bool
26
-     */
27
-    private $required;
28
-
29
-    /**
30
-     * Custom validation text displayed alongside a required form input to assist users with completing the form.
31
-     *
32
-     * @var string
33
-     */
34
-    private $validationText;
35
-
36
-
37
-    /**
38
-     * Required constructor.
39
-     *
40
-     * @param JsonDataHandler $json_data_handler
41
-     * @param bool            $required
42
-     * @param string          $validationText
43
-     */
44
-    public function __construct(JsonDataHandler $json_data_handler, bool $required, string $validationText)
45
-    {
46
-        $this->json_data_handler = $json_data_handler;
47
-        $this->setRequired($required);
48
-        $this->setValidationText($validationText);
49
-    }
50
-
51
-
52
-    /**
53
-     * @param string $json
54
-     * @return Required
55
-     */
56
-    public static function fromJson(string $json): Required
57
-    {
58
-        $json_data_handler = new JsonDataHandler();
59
-        $json_data_handler->configure(JsonDataHandler::DATA_TYPE_OBJECT);
60
-        $data           = $json_data_handler->decodeJson($json);
61
-        $required       = $data->required ?? false;
62
-        $validationText = $data->validationText ?? '';
63
-        return new Required($json_data_handler, $required, $validationText);
64
-    }
65
-
66
-
67
-    /**
68
-     * @return array
69
-     */
70
-    public function toArray(): array
71
-    {
72
-        return [
73
-            'required'       => $this->required,
74
-            'validationText' => $this->validationText,
75
-        ];
76
-    }
77
-
78
-
79
-    /**
80
-     * @return string
81
-     */
82
-    public function toJson(): string
83
-    {
84
-        return $this->json_data_handler->encodeData($this->toArray());
85
-    }
86
-
87
-
88
-    /**
89
-     *
90
-     *
91
-     * @return bool
92
-     */
93
-    public function isRequired(): ?bool
94
-    {
95
-        return $this->required;
96
-    }
97
-
98
-
99
-    /**
100
-     * @param bool|int|string $required
101
-     */
102
-    public function setRequired($required = true)
103
-    {
104
-        $this->required = filter_var($required, FILTER_VALIDATE_BOOLEAN);
105
-    }
106
-
107
-
108
-    /**
109
-     * @return string
110
-     */
111
-    public function validationText(): ?string
112
-    {
113
-        return $this->validationText;
114
-    }
115
-
116
-
117
-    /**
118
-     * @param string $validationText
119
-     */
120
-    public function setValidationText(string $validationText)
121
-    {
122
-        $this->validationText = sanitize_text_field($validationText);
123
-    }
18
+	/**
19
+	 * @var JsonDataHandler
20
+	 */
21
+	private $json_data_handler;
22
+
23
+	/** Whether or not the input must be supplied with a value in order to complete the form.
24
+	 *
25
+	 * @var bool
26
+	 */
27
+	private $required;
28
+
29
+	/**
30
+	 * Custom validation text displayed alongside a required form input to assist users with completing the form.
31
+	 *
32
+	 * @var string
33
+	 */
34
+	private $validationText;
35
+
36
+
37
+	/**
38
+	 * Required constructor.
39
+	 *
40
+	 * @param JsonDataHandler $json_data_handler
41
+	 * @param bool            $required
42
+	 * @param string          $validationText
43
+	 */
44
+	public function __construct(JsonDataHandler $json_data_handler, bool $required, string $validationText)
45
+	{
46
+		$this->json_data_handler = $json_data_handler;
47
+		$this->setRequired($required);
48
+		$this->setValidationText($validationText);
49
+	}
50
+
51
+
52
+	/**
53
+	 * @param string $json
54
+	 * @return Required
55
+	 */
56
+	public static function fromJson(string $json): Required
57
+	{
58
+		$json_data_handler = new JsonDataHandler();
59
+		$json_data_handler->configure(JsonDataHandler::DATA_TYPE_OBJECT);
60
+		$data           = $json_data_handler->decodeJson($json);
61
+		$required       = $data->required ?? false;
62
+		$validationText = $data->validationText ?? '';
63
+		return new Required($json_data_handler, $required, $validationText);
64
+	}
65
+
66
+
67
+	/**
68
+	 * @return array
69
+	 */
70
+	public function toArray(): array
71
+	{
72
+		return [
73
+			'required'       => $this->required,
74
+			'validationText' => $this->validationText,
75
+		];
76
+	}
77
+
78
+
79
+	/**
80
+	 * @return string
81
+	 */
82
+	public function toJson(): string
83
+	{
84
+		return $this->json_data_handler->encodeData($this->toArray());
85
+	}
86
+
87
+
88
+	/**
89
+	 *
90
+	 *
91
+	 * @return bool
92
+	 */
93
+	public function isRequired(): ?bool
94
+	{
95
+		return $this->required;
96
+	}
97
+
98
+
99
+	/**
100
+	 * @param bool|int|string $required
101
+	 */
102
+	public function setRequired($required = true)
103
+	{
104
+		$this->required = filter_var($required, FILTER_VALIDATE_BOOLEAN);
105
+	}
106
+
107
+
108
+	/**
109
+	 * @return string
110
+	 */
111
+	public function validationText(): ?string
112
+	{
113
+		return $this->validationText;
114
+	}
115
+
116
+
117
+	/**
118
+	 * @param string $validationText
119
+	 */
120
+	public function setValidationText(string $validationText)
121
+	{
122
+		$this->validationText = sanitize_text_field($validationText);
123
+	}
124 124
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/enums/ElementTypeEnum.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -17,24 +17,24 @@
 block discarded – undo
17 17
 class ElementTypeEnum extends EnumBase
18 18
 {
19 19
 
20
-    /**
21
-     * ElementTypeEnum constructor.
22
-     */
23
-    public function __construct()
24
-    {
25
-        $this->setName($this->namespace . 'ElementTypeEnum');
26
-        $this->setDescription(esc_html__('Form element type.', 'event_espresso'));
27
-        parent::__construct();
28
-    }
20
+	/**
21
+	 * ElementTypeEnum constructor.
22
+	 */
23
+	public function __construct()
24
+	{
25
+		$this->setName($this->namespace . 'ElementTypeEnum');
26
+		$this->setDescription(esc_html__('Form element type.', 'event_espresso'));
27
+		parent::__construct();
28
+	}
29 29
 
30 30
 
31
-    /**
32
-     * @return array
33
-     */
34
-    protected function getValues(): array
35
-    {
36
-        /** @var InputTypes $input_types */
37
-        $input_types = LoaderFactory::getShared('EventEspresso\core\services\form\meta\InputTypes');
38
-        return $input_types->getInputTypesValues();
39
-    }
31
+	/**
32
+	 * @return array
33
+	 */
34
+	protected function getValues(): array
35
+	{
36
+		/** @var InputTypes $input_types */
37
+		$input_types = LoaderFactory::getShared('EventEspresso\core\services\form\meta\InputTypes');
38
+		return $input_types->getInputTypesValues();
39
+	}
40 40
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
      */
23 23
     public function __construct()
24 24
     {
25
-        $this->setName($this->namespace . 'ElementTypeEnum');
25
+        $this->setName($this->namespace.'ElementTypeEnum');
26 26
         $this->setDescription(esc_html__('Form element type.', 'event_espresso'));
27 27
         parent::__construct();
28 28
     }
Please login to merge, or discard this patch.
core/domain/services/graphql/enums/FormStatusEnum.php 2 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -17,28 +17,28 @@
 block discarded – undo
17 17
 class FormStatusEnum extends EnumBase
18 18
 {
19 19
 
20
-    /**
21
-     * FormStatusEnum constructor.
22
-     */
23
-    public function __construct()
24
-    {
25
-        $this->setName($this->namespace . 'FormStatusEnum');
26
-        $this->setDescription(esc_html__(
27
-            'Whether form section or element is active, archived, shared, trashed, or used as a default on new forms.',
28
-            'event_espresso'
29
-        ));
30
-        parent::__construct();
31
-    }
20
+	/**
21
+	 * FormStatusEnum constructor.
22
+	 */
23
+	public function __construct()
24
+	{
25
+		$this->setName($this->namespace . 'FormStatusEnum');
26
+		$this->setDescription(esc_html__(
27
+			'Whether form section or element is active, archived, shared, trashed, or used as a default on new forms.',
28
+			'event_espresso'
29
+		));
30
+		parent::__construct();
31
+	}
32 32
 
33 33
 
34
-    /**
35
-     * @return array
36
-     */
37
-    protected function getValues(): array
38
-    {
39
-        /** @var FormStatus $form_status */
40
-        $form_status = LoaderFactory::getShared('EventEspresso\core\services\form\meta\FormStatus');
34
+	/**
35
+	 * @return array
36
+	 */
37
+	protected function getValues(): array
38
+	{
39
+		/** @var FormStatus $form_status */
40
+		$form_status = LoaderFactory::getShared('EventEspresso\core\services\form\meta\FormStatus');
41 41
 
42
-        return $form_status->getFormStatusValues();
43
-    }
42
+		return $form_status->getFormStatusValues();
43
+	}
44 44
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
      */
23 23
     public function __construct()
24 24
     {
25
-        $this->setName($this->namespace . 'FormStatusEnum');
25
+        $this->setName($this->namespace.'FormStatusEnum');
26 26
         $this->setDescription(esc_html__(
27 27
             'Whether form section or element is active, archived, shared, trashed, or used as a default on new forms.',
28 28
             'event_espresso'
Please login to merge, or discard this patch.
core/domain/services/graphql/data/mutations/FormElementMutation.php 2 patches
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -18,74 +18,74 @@
 block discarded – undo
18 18
 class FormElementMutation
19 19
 {
20 20
 
21
-    /**
22
-     * Maps the GraphQL input to a format that the model functions can use
23
-     *
24
-     * @param array $input Data coming from the GraphQL mutation query input
25
-     * @return array
26
-     */
27
-    public static function prepareFields(array $input): array
28
-    {
29
-        $args = [];
30
-
31
-        if (isset($input['id'])) {
32
-            $args['FIN_UUID'] = sanitize_text_field($input['id']);
33
-        }
34
-
35
-        if (isset($input['adminOnly'])) {
36
-            $args['FIN_adminOnly'] = (bool) $input['adminOnly'];
37
-        }
38
-
39
-        if (isset($input['attributes'])) {
40
-            $args['FIN_attributes'] = Attributes::fromJson(sanitize_text_field($input['attributes']))->toJson();
41
-        }
42
-
43
-        if (isset($input['belongsTo'])) {
44
-            $args['FSC_UUID'] = sanitize_text_field($input['belongsTo']);
45
-        }
46
-
47
-        if (isset($input['helpText'])) {
48
-            $args['FIN_helpText'] = HelpText::fromJson(sanitize_text_field($input['helpText']))->toJson();
49
-        }
50
-
51
-        if (isset($input['label'])) {
52
-            $args['FIN_label'] = FormLabel::fromJson(sanitize_text_field($input['label']))->toJson();
53
-        }
54
-
55
-        if (isset($input['mapsTo'])) {
56
-            $args['FIN_mapsTo'] = sanitize_text_field($input['mapsTo']);
57
-        }
58
-
59
-        if (isset($input['options'])) {
60
-            $args['FIN_options'] = InputOptions::fromJson(sanitize_text_field($input['options']))->toJson();
61
-        }
62
-
63
-        // order can be 0
64
-        if (array_key_exists('order', $input)) {
65
-            $args['FIN_order'] = absint($input['order']);
66
-        }
67
-
68
-        if (isset($input['required'])) {
69
-            $args['FIN_required'] = Required::fromJson(sanitize_text_field($input['required']))->toJson();
70
-        }
71
-
72
-        if (isset($input['status'])) {
73
-            $args['FIN_status'] = sanitize_text_field($input['status']);
74
-        }
75
-
76
-        if (isset($input['type'])) {
77
-            $args['FIN_type'] = sanitize_text_field($input['type']);
78
-        }
79
-
80
-        if (! empty($input['wpUser'])) {
81
-            $parts = Relay::fromGlobalId(sanitize_text_field($input['wpUser']));
82
-            $args['FIN_wpUser'] = ! empty($parts['id']) ? $parts['id'] : null;
83
-        }
84
-
85
-        return apply_filters(
86
-            'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__form_element_args',
87
-            $args,
88
-            $input
89
-        );
90
-    }
21
+	/**
22
+	 * Maps the GraphQL input to a format that the model functions can use
23
+	 *
24
+	 * @param array $input Data coming from the GraphQL mutation query input
25
+	 * @return array
26
+	 */
27
+	public static function prepareFields(array $input): array
28
+	{
29
+		$args = [];
30
+
31
+		if (isset($input['id'])) {
32
+			$args['FIN_UUID'] = sanitize_text_field($input['id']);
33
+		}
34
+
35
+		if (isset($input['adminOnly'])) {
36
+			$args['FIN_adminOnly'] = (bool) $input['adminOnly'];
37
+		}
38
+
39
+		if (isset($input['attributes'])) {
40
+			$args['FIN_attributes'] = Attributes::fromJson(sanitize_text_field($input['attributes']))->toJson();
41
+		}
42
+
43
+		if (isset($input['belongsTo'])) {
44
+			$args['FSC_UUID'] = sanitize_text_field($input['belongsTo']);
45
+		}
46
+
47
+		if (isset($input['helpText'])) {
48
+			$args['FIN_helpText'] = HelpText::fromJson(sanitize_text_field($input['helpText']))->toJson();
49
+		}
50
+
51
+		if (isset($input['label'])) {
52
+			$args['FIN_label'] = FormLabel::fromJson(sanitize_text_field($input['label']))->toJson();
53
+		}
54
+
55
+		if (isset($input['mapsTo'])) {
56
+			$args['FIN_mapsTo'] = sanitize_text_field($input['mapsTo']);
57
+		}
58
+
59
+		if (isset($input['options'])) {
60
+			$args['FIN_options'] = InputOptions::fromJson(sanitize_text_field($input['options']))->toJson();
61
+		}
62
+
63
+		// order can be 0
64
+		if (array_key_exists('order', $input)) {
65
+			$args['FIN_order'] = absint($input['order']);
66
+		}
67
+
68
+		if (isset($input['required'])) {
69
+			$args['FIN_required'] = Required::fromJson(sanitize_text_field($input['required']))->toJson();
70
+		}
71
+
72
+		if (isset($input['status'])) {
73
+			$args['FIN_status'] = sanitize_text_field($input['status']);
74
+		}
75
+
76
+		if (isset($input['type'])) {
77
+			$args['FIN_type'] = sanitize_text_field($input['type']);
78
+		}
79
+
80
+		if (! empty($input['wpUser'])) {
81
+			$parts = Relay::fromGlobalId(sanitize_text_field($input['wpUser']));
82
+			$args['FIN_wpUser'] = ! empty($parts['id']) ? $parts['id'] : null;
83
+		}
84
+
85
+		return apply_filters(
86
+			'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__form_element_args',
87
+			$args,
88
+			$input
89
+		);
90
+	}
91 91
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@
 block discarded – undo
77 77
             $args['FIN_type'] = sanitize_text_field($input['type']);
78 78
         }
79 79
 
80
-        if (! empty($input['wpUser'])) {
80
+        if ( ! empty($input['wpUser'])) {
81 81
             $parts = Relay::fromGlobalId(sanitize_text_field($input['wpUser']));
82 82
             $args['FIN_wpUser'] = ! empty($parts['id']) ? $parts['id'] : null;
83 83
         }
Please login to merge, or discard this patch.
core/domain/services/graphql/types/FormElement.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
      */
35 35
     public function __construct(EEM_Form_Element $form_element_model)
36 36
     {
37
-        $this->setName($this->namespace . 'FormElement');
37
+        $this->setName($this->namespace.'FormElement');
38 38
         $this->setDescription(__('A form element', 'event_espresso'));
39 39
         $this->setIsCustomPostType(false);
40 40
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
             ),
134 134
             new GraphQLField(
135 135
                 'status',
136
-                $this->namespace . 'FormStatusEnum',
136
+                $this->namespace.'FormStatusEnum',
137 137
                 'status',
138 138
                 esc_html__(
139 139
                     'Whether form element is active, archived, trashed, or used as a default on new forms.',
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
             ),
143 143
             new GraphQLField(
144 144
                 'type',
145
-                $this->namespace . 'ElementTypeEnum',
145
+                $this->namespace.'ElementTypeEnum',
146 146
                 'type',
147 147
                 esc_html__('Form element type.', 'event_espresso')
148 148
             ),
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
     {
181 181
         // Register mutation to update an entity.
182 182
         register_graphql_mutation(
183
-            'update' . $this->name(),
183
+            'update'.$this->name(),
184 184
             [
185 185
                 'inputFields'         => $inputFields,
186 186
                 'outputFields'        => [
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
         );
195 195
         // Register mutation to delete an entity.
196 196
         register_graphql_mutation(
197
-            'delete' . $this->name(),
197
+            'delete'.$this->name(),
198 198
             [
199 199
                 'inputFields'         => [
200 200
                     'id' => $inputFields['id'],
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
                     lcfirst($this->name()) => [
204 204
                         'type'        => $this->name(),
205 205
                         'description' => esc_html__('The object before it was deleted', 'event_espresso'),
206
-                        'resolve'     => static function ($payload) {
206
+                        'resolve'     => static function($payload) {
207 207
                             $deleted = (object) $payload['deleted'];
208 208
 
209 209
                             return ! empty($deleted) ? $deleted : null;
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 
221 221
         // Register mutation to update an entity.
222 222
         register_graphql_mutation(
223
-            'create' . $this->name(),
223
+            'create'.$this->name(),
224 224
             [
225 225
                 'inputFields'         => $inputFields,
226 226
                 'outputFields'        => [
Please login to merge, or discard this patch.
Indentation   +197 added lines, -197 removed lines patch added patch discarded remove patch
@@ -27,210 +27,210 @@
 block discarded – undo
27 27
 class FormElement extends TypeBase
28 28
 {
29 29
 
30
-    /**
31
-     * FormElement constructor.
32
-     *
33
-     * @param EEM_Form_Element $form_element_model
34
-     */
35
-    public function __construct(EEM_Form_Element $form_element_model)
36
-    {
37
-        $this->setName($this->namespace . 'FormElement');
38
-        $this->setDescription(__('A form element', 'event_espresso'));
39
-        $this->setIsCustomPostType(false);
30
+	/**
31
+	 * FormElement constructor.
32
+	 *
33
+	 * @param EEM_Form_Element $form_element_model
34
+	 */
35
+	public function __construct(EEM_Form_Element $form_element_model)
36
+	{
37
+		$this->setName($this->namespace . 'FormElement');
38
+		$this->setDescription(__('A form element', 'event_espresso'));
39
+		$this->setIsCustomPostType(false);
40 40
 
41
-        parent::__construct($form_element_model);
42
-    }
41
+		parent::__construct($form_element_model);
42
+	}
43 43
 
44 44
 
45
-    /**
46
-     * @return GraphQLFieldInterface[]
47
-     */
48
-    public function getFields(): array
49
-    {
50
-        $fields = [
51
-            new GraphQLField(
52
-                'id',
53
-                ['non_null' => 'ID'],
54
-                null,
55
-                esc_html__('The globally unique ID for the object.', 'event_espresso')
56
-            ),
57
-            new GraphQLField(
58
-                'adminOnly',
59
-                'Boolean',
60
-                'adminOnly',
61
-                esc_html__(
62
-                    'Whether or not the element is only displayed in the admin. If false, input will appear in public forms',
63
-                    'event_espresso'
64
-                )
65
-            ),
66
-            new GraphQLField(
67
-                'attributes',
68
-                'String',
69
-                'attributes',
70
-                esc_html__(
71
-                    'JSON string of HTML attributes such as class, max, min, placeholder, type, etc.',
72
-                    'event_espresso'
73
-                ),
74
-                [$this, 'toJson']
75
-            ),
76
-            new GraphQLField(
77
-                'belongsTo',
78
-                'String',
79
-                'belongsTo',
80
-                esc_html__('UUID of parent form section this form element belongs to.', 'event_espresso')
81
-            ),
82
-            new GraphQLField(
83
-                'helpText',
84
-                'String',
85
-                'helpText',
86
-                esc_html__(
87
-                    "JSON string of properties pertaining to any help text required for an input.",
88
-                    'event_espresso'
89
-                ),
90
-                [$this, 'toJson']
91
-            ),
92
-            new GraphQLField(
93
-                'label',
94
-                'String',
95
-                'label',
96
-                esc_html__(
97
-                    'JSON string of properties pertaining to an element\'s label.',
98
-                    'event_espresso'
99
-                ),
100
-                [$this, 'toJson']
101
-            ),
102
-            new GraphQLField(
103
-                'mapsTo',
104
-                'String',
105
-                'mapsTo',
106
-                esc_html__("Model and Fields name that this element maps to; ex: Attendee.email", 'event_espresso')
107
-            ),
108
-            new GraphQLField(
109
-                'options',
110
-                'String',
111
-                'options',
112
-                esc_html__(
113
-                    "JSON string of options for ENUM type inputs like checkboxes, radio buttons, select inputs, etc.",
114
-                    'event_espresso'
115
-                ),
116
-                [$this, 'toJson']
117
-            ),
118
-            new GraphQLField(
119
-                'order',
120
-                'Int',
121
-                'order',
122
-                esc_html__('Order in which form element appears in a form.', 'event_espresso')
123
-            ),
124
-            new GraphQLField(
125
-                'required',
126
-                'String',
127
-                'required',
128
-                esc_html__(
129
-                    "properties pertaining to an input\'s required status and the validation text to display.",
130
-                    'event_espresso'
131
-                ),
132
-                [$this, 'toJson']
133
-            ),
134
-            new GraphQLField(
135
-                'status',
136
-                $this->namespace . 'FormStatusEnum',
137
-                'status',
138
-                esc_html__(
139
-                    'Whether form element is active, archived, trashed, or used as a default on new forms.',
140
-                    'event_espresso'
141
-                )
142
-            ),
143
-            new GraphQLField(
144
-                'type',
145
-                $this->namespace . 'ElementTypeEnum',
146
-                'type',
147
-                esc_html__('Form element type.', 'event_espresso')
148
-            ),
149
-            new GraphQLOutputField(
150
-                'wpUser',
151
-                'User',
152
-                null,
153
-                esc_html__('WP User that created this form element.', 'event_espresso')
154
-            ),
155
-            new GraphQLInputField(
156
-                'wpUser',
157
-                'ID',
158
-                null,
159
-                esc_html__('ID of the WP User that created the form element.', 'event_espresso')
160
-            ),
161
-        ];
45
+	/**
46
+	 * @return GraphQLFieldInterface[]
47
+	 */
48
+	public function getFields(): array
49
+	{
50
+		$fields = [
51
+			new GraphQLField(
52
+				'id',
53
+				['non_null' => 'ID'],
54
+				null,
55
+				esc_html__('The globally unique ID for the object.', 'event_espresso')
56
+			),
57
+			new GraphQLField(
58
+				'adminOnly',
59
+				'Boolean',
60
+				'adminOnly',
61
+				esc_html__(
62
+					'Whether or not the element is only displayed in the admin. If false, input will appear in public forms',
63
+					'event_espresso'
64
+				)
65
+			),
66
+			new GraphQLField(
67
+				'attributes',
68
+				'String',
69
+				'attributes',
70
+				esc_html__(
71
+					'JSON string of HTML attributes such as class, max, min, placeholder, type, etc.',
72
+					'event_espresso'
73
+				),
74
+				[$this, 'toJson']
75
+			),
76
+			new GraphQLField(
77
+				'belongsTo',
78
+				'String',
79
+				'belongsTo',
80
+				esc_html__('UUID of parent form section this form element belongs to.', 'event_espresso')
81
+			),
82
+			new GraphQLField(
83
+				'helpText',
84
+				'String',
85
+				'helpText',
86
+				esc_html__(
87
+					"JSON string of properties pertaining to any help text required for an input.",
88
+					'event_espresso'
89
+				),
90
+				[$this, 'toJson']
91
+			),
92
+			new GraphQLField(
93
+				'label',
94
+				'String',
95
+				'label',
96
+				esc_html__(
97
+					'JSON string of properties pertaining to an element\'s label.',
98
+					'event_espresso'
99
+				),
100
+				[$this, 'toJson']
101
+			),
102
+			new GraphQLField(
103
+				'mapsTo',
104
+				'String',
105
+				'mapsTo',
106
+				esc_html__("Model and Fields name that this element maps to; ex: Attendee.email", 'event_espresso')
107
+			),
108
+			new GraphQLField(
109
+				'options',
110
+				'String',
111
+				'options',
112
+				esc_html__(
113
+					"JSON string of options for ENUM type inputs like checkboxes, radio buttons, select inputs, etc.",
114
+					'event_espresso'
115
+				),
116
+				[$this, 'toJson']
117
+			),
118
+			new GraphQLField(
119
+				'order',
120
+				'Int',
121
+				'order',
122
+				esc_html__('Order in which form element appears in a form.', 'event_espresso')
123
+			),
124
+			new GraphQLField(
125
+				'required',
126
+				'String',
127
+				'required',
128
+				esc_html__(
129
+					"properties pertaining to an input\'s required status and the validation text to display.",
130
+					'event_espresso'
131
+				),
132
+				[$this, 'toJson']
133
+			),
134
+			new GraphQLField(
135
+				'status',
136
+				$this->namespace . 'FormStatusEnum',
137
+				'status',
138
+				esc_html__(
139
+					'Whether form element is active, archived, trashed, or used as a default on new forms.',
140
+					'event_espresso'
141
+				)
142
+			),
143
+			new GraphQLField(
144
+				'type',
145
+				$this->namespace . 'ElementTypeEnum',
146
+				'type',
147
+				esc_html__('Form element type.', 'event_espresso')
148
+			),
149
+			new GraphQLOutputField(
150
+				'wpUser',
151
+				'User',
152
+				null,
153
+				esc_html__('WP User that created this form element.', 'event_espresso')
154
+			),
155
+			new GraphQLInputField(
156
+				'wpUser',
157
+				'ID',
158
+				null,
159
+				esc_html__('ID of the WP User that created the form element.', 'event_espresso')
160
+			),
161
+		];
162 162
 
163
-        return apply_filters(
164
-            'FHEE__EventEspresso_core_domain_services_graphql_types__form_element_fields',
165
-            $fields,
166
-            $this->name,
167
-            $this->model
168
-        );
169
-    }
163
+		return apply_filters(
164
+			'FHEE__EventEspresso_core_domain_services_graphql_types__form_element_fields',
165
+			$fields,
166
+			$this->name,
167
+			$this->model
168
+		);
169
+	}
170 170
 
171 171
 
172
-    /**
173
-     * @param array $inputFields The mutation input fields.
174
-     * @throws InvalidArgumentException
175
-     * @throws ReflectionException
176
-     * @throws Exception
177
-     * @since $VID:$
178
-     */
179
-    public function registerMutations(array $inputFields)
180
-    {
181
-        // Register mutation to update an entity.
182
-        register_graphql_mutation(
183
-            'update' . $this->name(),
184
-            [
185
-                'inputFields'         => $inputFields,
186
-                'outputFields'        => [
187
-                    lcfirst($this->name()) => [
188
-                        'type'    => $this->name(),
189
-                        'resolve' => [$this, 'resolveFromPayload'],
190
-                    ],
191
-                ],
192
-                'mutateAndGetPayload' => FormElementUpdate::mutateAndGetPayload($this->model),
193
-            ]
194
-        );
195
-        // Register mutation to delete an entity.
196
-        register_graphql_mutation(
197
-            'delete' . $this->name(),
198
-            [
199
-                'inputFields'         => [
200
-                    'id' => $inputFields['id'],
201
-                ],
202
-                'outputFields'        => [
203
-                    lcfirst($this->name()) => [
204
-                        'type'        => $this->name(),
205
-                        'description' => esc_html__('The object before it was deleted', 'event_espresso'),
206
-                        'resolve'     => static function ($payload) {
207
-                            $deleted = (object) $payload['deleted'];
172
+	/**
173
+	 * @param array $inputFields The mutation input fields.
174
+	 * @throws InvalidArgumentException
175
+	 * @throws ReflectionException
176
+	 * @throws Exception
177
+	 * @since $VID:$
178
+	 */
179
+	public function registerMutations(array $inputFields)
180
+	{
181
+		// Register mutation to update an entity.
182
+		register_graphql_mutation(
183
+			'update' . $this->name(),
184
+			[
185
+				'inputFields'         => $inputFields,
186
+				'outputFields'        => [
187
+					lcfirst($this->name()) => [
188
+						'type'    => $this->name(),
189
+						'resolve' => [$this, 'resolveFromPayload'],
190
+					],
191
+				],
192
+				'mutateAndGetPayload' => FormElementUpdate::mutateAndGetPayload($this->model),
193
+			]
194
+		);
195
+		// Register mutation to delete an entity.
196
+		register_graphql_mutation(
197
+			'delete' . $this->name(),
198
+			[
199
+				'inputFields'         => [
200
+					'id' => $inputFields['id'],
201
+				],
202
+				'outputFields'        => [
203
+					lcfirst($this->name()) => [
204
+						'type'        => $this->name(),
205
+						'description' => esc_html__('The object before it was deleted', 'event_espresso'),
206
+						'resolve'     => static function ($payload) {
207
+							$deleted = (object) $payload['deleted'];
208 208
 
209
-                            return ! empty($deleted) ? $deleted : null;
210
-                        },
211
-                    ],
212
-                ],
213
-                'mutateAndGetPayload' => FormElementDelete::mutateAndGetPayload($this->model),
214
-            ]
215
-        );
209
+							return ! empty($deleted) ? $deleted : null;
210
+						},
211
+					],
212
+				],
213
+				'mutateAndGetPayload' => FormElementDelete::mutateAndGetPayload($this->model),
214
+			]
215
+		);
216 216
 
217
-        // Make element 'type' a required field for create mutations
218
-        // Yes it's "['type']['type']" 
Please login to merge, or discard this patch.