Completed
Branch FET/reg-form-v2 (f85ea5)
by
unknown
06:45 queued 04:35
created
core/domain/services/registration/form/v2/FormInputValidationStrategies.php 1 patch
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -16,62 +16,62 @@
 block discarded – undo
16 16
 
17 17
 class FormInputValidationStrategies
18 18
 {
19
-    /**
20
-     * @var FieldLengthCalculator
21
-     */
22
-    public $field_length_calculator;
19
+	/**
20
+	 * @var FieldLengthCalculator
21
+	 */
22
+	public $field_length_calculator;
23 23
 
24 24
 
25
-    /**
26
-     * FormInputFactory constructor.
27
-     *
28
-     * @param FieldLengthCalculator $field_length_calculator
29
-     */
30
-    public function __construct(FieldLengthCalculator $field_length_calculator)
31
-    {
32
-        $this->field_length_calculator = $field_length_calculator;
33
-    }
25
+	/**
26
+	 * FormInputFactory constructor.
27
+	 *
28
+	 * @param FieldLengthCalculator $field_length_calculator
29
+	 */
30
+	public function __construct(FieldLengthCalculator $field_length_calculator)
31
+	{
32
+		$this->field_length_calculator = $field_length_calculator;
33
+	}
34 34
 
35 35
 
36
-    /**
37
-     * @param EE_Form_Element $form_input
38
-     * @param array           $input_args
39
-     * @return array
40
-     * @throws EE_Error
41
-     * @throws ReflectionException
42
-     */
43
-    public function applyValidationStrategies(EE_Form_Element $form_input, array $input_args): array
44
-    {
45
-        if ($form_input->getAttribute('max') !== EE_INF || $form_input->mapsTo()) {
46
-            $max_field_length = $this->field_length_calculator->getMaxFieldLengthForInput($form_input);
47
-            if ($max_field_length !== EE_INF) {
48
-                $input_args['validation_strategies'][] = new EE_Max_Length_Validation_Strategy(
49
-                    null,
50
-                    $max_field_length
51
-                );
52
-            }
53
-        }
54
-        if ($form_input->getAttribute('min') > 0 || $form_input->mapsTo()) {
55
-            $min_field_length = $this->field_length_calculator->getMinFieldLengthForInput($form_input);
56
-            if ($min_field_length !== EE_INF) {
57
-                $input_args['validation_strategies'][] = new EE_Min_Length_Validation_Strategy(
58
-                    null,
59
-                    $min_field_length
60
-                );
61
-            }
62
-        }
36
+	/**
37
+	 * @param EE_Form_Element $form_input
38
+	 * @param array           $input_args
39
+	 * @return array
40
+	 * @throws EE_Error
41
+	 * @throws ReflectionException
42
+	 */
43
+	public function applyValidationStrategies(EE_Form_Element $form_input, array $input_args): array
44
+	{
45
+		if ($form_input->getAttribute('max') !== EE_INF || $form_input->mapsTo()) {
46
+			$max_field_length = $this->field_length_calculator->getMaxFieldLengthForInput($form_input);
47
+			if ($max_field_length !== EE_INF) {
48
+				$input_args['validation_strategies'][] = new EE_Max_Length_Validation_Strategy(
49
+					null,
50
+					$max_field_length
51
+				);
52
+			}
53
+		}
54
+		if ($form_input->getAttribute('min') > 0 || $form_input->mapsTo()) {
55
+			$min_field_length = $this->field_length_calculator->getMinFieldLengthForInput($form_input);
56
+			if ($min_field_length !== EE_INF) {
57
+				$input_args['validation_strategies'][] = new EE_Min_Length_Validation_Strategy(
58
+					null,
59
+					$min_field_length
60
+				);
61
+			}
62
+		}
63 63
 
64
-        if ($form_input->type() === Text::TYPE_TEXTAREA) {
65
-            $input_args['validation_strategies'][] = new EE_Simple_HTML_Validation_Strategy();
66
-        }
64
+		if ($form_input->type() === Text::TYPE_TEXTAREA) {
65
+			$input_args['validation_strategies'][] = new EE_Simple_HTML_Validation_Strategy();
66
+		}
67 67
 
68
-        if ($form_input->type() === Text::TYPE_TEXTAREA_HTML) {
69
-            $input_args['validation_strategies'][] = new EE_Full_HTML_Validation_Strategy();
70
-        }
68
+		if ($form_input->type() === Text::TYPE_TEXTAREA_HTML) {
69
+			$input_args['validation_strategies'][] = new EE_Full_HTML_Validation_Strategy();
70
+		}
71 71
 
72
-        if ($form_input->type() === Input::TYPE_URL) {
73
-            $input_args['validation_strategies'][] = LoaderFactory::getNew(EE_URL_Validation_Strategy::class);
74
-        }
75
-        return $input_args;
76
-    }
72
+		if ($form_input->type() === Input::TYPE_URL) {
73
+			$input_args['validation_strategies'][] = LoaderFactory::getNew(EE_URL_Validation_Strategy::class);
74
+		}
75
+		return $input_args;
76
+	}
77 77
 }
Please login to merge, or discard this patch.
core/domain/services/registration/form/v2/FormInputFactory.php 2 patches
Indentation   +218 added lines, -218 removed lines patch added patch discarded remove patch
@@ -34,225 +34,225 @@
 block discarded – undo
34 34
 
35 35
 class FormInputFactory
36 36
 {
37
-    /**
38
-     * @var stdClass
39
-     */
40
-    private $config;
41
-
42
-    /**
43
-     * @var FormInputValidationStrategies
44
-     */
45
-    public $validation_strategies;
46
-
47
-
48
-    /**
49
-     * FormInputFactory constructor.
50
-     *
51
-     * @param FormInputValidationStrategies $validation_strategies
52
-     */
53
-    public function __construct(FormInputValidationStrategies $validation_strategies)
54
-    {
55
-        $this->validation_strategies           = $validation_strategies;
56
-        $this->config                          = new stdClass();
57
-        $days                                  = range(1, 31);
58
-        $months                                = range(1, 12);
59
-        $this->config->days                    = array_combine($days, $days);
60
-        $this->config->months                  = array_combine($months, $months);
61
-        $this->config->year_input              = new stdClass();
62
-        $this->config->year_input->four_digit  = (bool) apply_filters(
63
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__four_digit',
64
-            true,
65
-            $this
66
-        );
67
-        $this->config->year_input->early_range = (int) apply_filters(
68
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__early_range',
69
-            100,
70
-            $this
71
-        );
72
-        $this->config->year_input->end_range   = (int) apply_filters(
73
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__end_range',
74
-            100,
75
-            $this
76
-        );
77
-    }
78
-
79
-
80
-    /**
81
-     * @param EE_Registration  $registration
82
-     * @param EE_Form_Element  $form_input
83
-     * @param int|float|string $answer
84
-     * @return EE_Form_Input_Base|null
85
-     * @throws EE_Error
86
-     * @throws ReflectionException
87
-     */
88
-    public function create(
89
-        EE_Registration $registration,
90
-        EE_Form_Element $form_input,
91
-        $answer
92
-    ): ?EE_Form_Input_Base {
93
-        $input_args = (array) apply_filters(
94
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__input_constructor_args',
95
-            $this->generateInputArgs($registration, $form_input, $answer),
96
-            $registration,
97
-            $this,
98
-            $answer
99
-        );
100
-        return $this->getInput($form_input, $input_args);
101
-    }
102
-
103
-
104
-    /**
105
-     * @param EE_Registration  $registration
106
-     * @param EE_Form_Element  $form_input
107
-     * @param int|float|string $answer
108
-     * @return array
109
-     * @throws EE_Error
110
-     * @throws ReflectionException
111
-     */
112
-    private function generateInputArgs(EE_Registration $registration, EE_Form_Element $form_input, $answer): array
113
-    {
114
-        $identifier = $form_input->slug();
115
-        $reg_id     = $registration->ID();
116
-        $label      = $form_input->label();
117
-        $required   = $form_input->required();
118
-        // group_name
119
-        $input_args = [
120
-            'default'                           => $answer,
121
-            'html_name'                         => "ee_reg_qstn[$reg_id][$identifier]",
122
-            'html_id'                           => "ee_reg_qstn-$reg_id-$identifier",
123
-            'html_class'                        => "ee-reg-qstn ee-reg-qstn-$identifier",
124
-            'html_label_id'                     => "ee_reg_qstn-$reg_id-$identifier-lbl",
125
-            'html_label_class'                  => 'ee-reg-qstn',
126
-            'html_label_text'                   => $label instanceof FormLabel ? $label->publicLabel() : '',
127
-            'required'                          => $required instanceof Required ? $required->isRequired() : false,
128
-            'required_validation_error_message' => $required instanceof Required ? $required->validationText() : '',
129
-        ];
130
-        return $this->validation_strategies->applyValidationStrategies($form_input, $input_args);
131
-    }
132
-
133
-
134
-    /**
135
-     * @param EE_Form_Element $form_input
136
-     * @param array           $input_args
137
-     * @return EE_Form_Input_Base|null
138
-     * @throws EE_Error
139
-     * @throws ReflectionException
140
-     */
141
-    private function getInput(EE_Form_Element $form_input, array $input_args): ?EE_Form_Input_Base
142
-    {
143
-        $input_options = $form_input->options();
144
-        $options       = $input_options instanceof InputOptions ? $input_options->options() : [];
145
-        switch ($form_input->type()) {
146
-
147
-            // date type inputs
148
-            case DateTime::TYPE_DATE:
149
-                return new EE_Datepicker_Input($input_args);
150
-
151
-            case DateTime::TYPE_DATETIME_LOCAL:
152
-                $input_args['type'] = 'datetime-local';
153
-                return new EE_Text_Input($input_args);
154
-
155
-            case DateTime::TYPE_MONTH:
156
-                $input_args['type'] = 'month';
157
-                return new EE_Text_Input($input_args);
158
-
159
-            case DateTime::TYPE_TIME:
160
-                $input_args['type'] = 'time';
161
-                return new EE_Text_Input($input_args);
162
-
163
-            case DateTime::TYPE_WEEK:
164
-                $input_args['type'] = 'week';
165
-                return new EE_Text_Input($input_args);
166
-
167
-            case DateTime::TYPE_SELECT_DAY:
168
-                return new EE_Select_Input($this->config->days, $input_args);
169
-
170
-            case DateTime::TYPE_SELECT_MONTH:
171
-                return new EE_Select_Input($this->config->months, $input_args);
172
-
173
-            case DateTime::TYPE_SELECT_YEAR:
174
-                return new EE_Year_Input(
175
-                    $input_args,
176
-                    $this->config->year_input->four_digit,
177
-                    $this->config->year_input->early_range,
178
-                    $this->config->year_input->end_range
179
-                );
180
-
181
-            // input type inputs (???)
182
-            case Input::TYPE_CHECKBOX:
183
-                return new EE_Checkbox_Multi_Input($options, $input_args);
184
-
185
-            case Input::TYPE_COLOR:
186
-                $input_args['type'] = 'color';
187
-                return new EE_Text_Input($input_args);
188
-
189
-            case Input::TYPE_FILE:
190
-                $input_args['type'] = 'file';
191
-                return new EE_Text_Input($input_args);
192
-
193
-            case Input::TYPE_HIDDEN:
194
-                $input_args['type'] = 'hidden';
195
-                return new EE_Text_Input($input_args);
196
-
197
-            case Input::TYPE_IMAGE:
198
-                $input_args['type'] = 'image';
199
-                return new EE_Text_Input($input_args);
200
-
201
-            case Input::TYPE_PASSWORD:
202
-                $input_args['type'] = 'password';
203
-                return new EE_Text_Input($input_args);
204
-
205
-            case Input::TYPE_URL:
206
-                $input_args['type'] = 'url';
207
-                return new EE_Text_Input($input_args);
208
-
209
-            case Input::TYPE_RADIO:
210
-                return new EE_Radio_Button_Input($options, $input_args);
211
-
212
-            // numeric type inputs
213
-            case Number::TYPE_FLOAT:
214
-                return new EE_Float_Input($input_args);
215
-
216
-            case Number::TYPE_INT:
217
-                return new EE_Integer_Input($input_args);
218
-
219
-            case Number::TYPE_RANGE:
220
-                $input_args['type'] = 'range';
221
-                return new EE_Text_Input($input_args);
222
-
223
-            // phone type inputs
224
-            case Phone::INPUT_TYPE:
225
-                $input_args['type'] = 'tel';
226
-                return new EE_Text_Input($input_args);
227
-            // return new EE_Phone_Input($input_args);
228
-
229
-            // select type inputs
230
-            case Select::TYPE_SELECT:
231
-                return new EE_Select_Input($options, $input_args);
232
-
233
-            case Select::TYPE_SELECT_COUNTRY:
234
-                return new EE_Country_Select_Input([], $input_args);
235
-
236
-            case Select::TYPE_SELECT_STATE:
237
-                return new EE_State_Select_Input([], $input_args);
238
-
239
-            case Select::TYPE_SELECT_MULTI:
240
-                return new EE_Select_Multiple_Input($options, $input_args);
241
-
242
-            // text type inputs
243
-            case Text::TYPE_TEXTAREA:
244
-            case Text::TYPE_TEXTAREA_HTML:
245
-                return new EE_Text_Area_Input($input_args);
37
+	/**
38
+	 * @var stdClass
39
+	 */
40
+	private $config;
41
+
42
+	/**
43
+	 * @var FormInputValidationStrategies
44
+	 */
45
+	public $validation_strategies;
46
+
47
+
48
+	/**
49
+	 * FormInputFactory constructor.
50
+	 *
51
+	 * @param FormInputValidationStrategies $validation_strategies
52
+	 */
53
+	public function __construct(FormInputValidationStrategies $validation_strategies)
54
+	{
55
+		$this->validation_strategies           = $validation_strategies;
56
+		$this->config                          = new stdClass();
57
+		$days                                  = range(1, 31);
58
+		$months                                = range(1, 12);
59
+		$this->config->days                    = array_combine($days, $days);
60
+		$this->config->months                  = array_combine($months, $months);
61
+		$this->config->year_input              = new stdClass();
62
+		$this->config->year_input->four_digit  = (bool) apply_filters(
63
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__four_digit',
64
+			true,
65
+			$this
66
+		);
67
+		$this->config->year_input->early_range = (int) apply_filters(
68
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__early_range',
69
+			100,
70
+			$this
71
+		);
72
+		$this->config->year_input->end_range   = (int) apply_filters(
73
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__end_range',
74
+			100,
75
+			$this
76
+		);
77
+	}
78
+
79
+
80
+	/**
81
+	 * @param EE_Registration  $registration
82
+	 * @param EE_Form_Element  $form_input
83
+	 * @param int|float|string $answer
84
+	 * @return EE_Form_Input_Base|null
85
+	 * @throws EE_Error
86
+	 * @throws ReflectionException
87
+	 */
88
+	public function create(
89
+		EE_Registration $registration,
90
+		EE_Form_Element $form_input,
91
+		$answer
92
+	): ?EE_Form_Input_Base {
93
+		$input_args = (array) apply_filters(
94
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__input_constructor_args',
95
+			$this->generateInputArgs($registration, $form_input, $answer),
96
+			$registration,
97
+			$this,
98
+			$answer
99
+		);
100
+		return $this->getInput($form_input, $input_args);
101
+	}
102
+
103
+
104
+	/**
105
+	 * @param EE_Registration  $registration
106
+	 * @param EE_Form_Element  $form_input
107
+	 * @param int|float|string $answer
108
+	 * @return array
109
+	 * @throws EE_Error
110
+	 * @throws ReflectionException
111
+	 */
112
+	private function generateInputArgs(EE_Registration $registration, EE_Form_Element $form_input, $answer): array
113
+	{
114
+		$identifier = $form_input->slug();
115
+		$reg_id     = $registration->ID();
116
+		$label      = $form_input->label();
117
+		$required   = $form_input->required();
118
+		// group_name
119
+		$input_args = [
120
+			'default'                           => $answer,
121
+			'html_name'                         => "ee_reg_qstn[$reg_id][$identifier]",
122
+			'html_id'                           => "ee_reg_qstn-$reg_id-$identifier",
123
+			'html_class'                        => "ee-reg-qstn ee-reg-qstn-$identifier",
124
+			'html_label_id'                     => "ee_reg_qstn-$reg_id-$identifier-lbl",
125
+			'html_label_class'                  => 'ee-reg-qstn',
126
+			'html_label_text'                   => $label instanceof FormLabel ? $label->publicLabel() : '',
127
+			'required'                          => $required instanceof Required ? $required->isRequired() : false,
128
+			'required_validation_error_message' => $required instanceof Required ? $required->validationText() : '',
129
+		];
130
+		return $this->validation_strategies->applyValidationStrategies($form_input, $input_args);
131
+	}
132
+
133
+
134
+	/**
135
+	 * @param EE_Form_Element $form_input
136
+	 * @param array           $input_args
137
+	 * @return EE_Form_Input_Base|null
138
+	 * @throws EE_Error
139
+	 * @throws ReflectionException
140
+	 */
141
+	private function getInput(EE_Form_Element $form_input, array $input_args): ?EE_Form_Input_Base
142
+	{
143
+		$input_options = $form_input->options();
144
+		$options       = $input_options instanceof InputOptions ? $input_options->options() : [];
145
+		switch ($form_input->type()) {
146
+
147
+			// date type inputs
148
+			case DateTime::TYPE_DATE:
149
+				return new EE_Datepicker_Input($input_args);
150
+
151
+			case DateTime::TYPE_DATETIME_LOCAL:
152
+				$input_args['type'] = 'datetime-local';
153
+				return new EE_Text_Input($input_args);
154
+
155
+			case DateTime::TYPE_MONTH:
156
+				$input_args['type'] = 'month';
157
+				return new EE_Text_Input($input_args);
158
+
159
+			case DateTime::TYPE_TIME:
160
+				$input_args['type'] = 'time';
161
+				return new EE_Text_Input($input_args);
162
+
163
+			case DateTime::TYPE_WEEK:
164
+				$input_args['type'] = 'week';
165
+				return new EE_Text_Input($input_args);
166
+
167
+			case DateTime::TYPE_SELECT_DAY:
168
+				return new EE_Select_Input($this->config->days, $input_args);
169
+
170
+			case DateTime::TYPE_SELECT_MONTH:
171
+				return new EE_Select_Input($this->config->months, $input_args);
172
+
173
+			case DateTime::TYPE_SELECT_YEAR:
174
+				return new EE_Year_Input(
175
+					$input_args,
176
+					$this->config->year_input->four_digit,
177
+					$this->config->year_input->early_range,
178
+					$this->config->year_input->end_range
179
+				);
180
+
181
+			// input type inputs (???)
182
+			case Input::TYPE_CHECKBOX:
183
+				return new EE_Checkbox_Multi_Input($options, $input_args);
184
+
185
+			case Input::TYPE_COLOR:
186
+				$input_args['type'] = 'color';
187
+				return new EE_Text_Input($input_args);
188
+
189
+			case Input::TYPE_FILE:
190
+				$input_args['type'] = 'file';
191
+				return new EE_Text_Input($input_args);
192
+
193
+			case Input::TYPE_HIDDEN:
194
+				$input_args['type'] = 'hidden';
195
+				return new EE_Text_Input($input_args);
196
+
197
+			case Input::TYPE_IMAGE:
198
+				$input_args['type'] = 'image';
199
+				return new EE_Text_Input($input_args);
200
+
201
+			case Input::TYPE_PASSWORD:
202
+				$input_args['type'] = 'password';
203
+				return new EE_Text_Input($input_args);
204
+
205
+			case Input::TYPE_URL:
206
+				$input_args['type'] = 'url';
207
+				return new EE_Text_Input($input_args);
208
+
209
+			case Input::TYPE_RADIO:
210
+				return new EE_Radio_Button_Input($options, $input_args);
211
+
212
+			// numeric type inputs
213
+			case Number::TYPE_FLOAT:
214
+				return new EE_Float_Input($input_args);
215
+
216
+			case Number::TYPE_INT:
217
+				return new EE_Integer_Input($input_args);
218
+
219
+			case Number::TYPE_RANGE:
220
+				$input_args['type'] = 'range';
221
+				return new EE_Text_Input($input_args);
222
+
223
+			// phone type inputs
224
+			case Phone::INPUT_TYPE:
225
+				$input_args['type'] = 'tel';
226
+				return new EE_Text_Input($input_args);
227
+			// return new EE_Phone_Input($input_args);
228
+
229
+			// select type inputs
230
+			case Select::TYPE_SELECT:
231
+				return new EE_Select_Input($options, $input_args);
232
+
233
+			case Select::TYPE_SELECT_COUNTRY:
234
+				return new EE_Country_Select_Input([], $input_args);
235
+
236
+			case Select::TYPE_SELECT_STATE:
237
+				return new EE_State_Select_Input([], $input_args);
238
+
239
+			case Select::TYPE_SELECT_MULTI:
240
+				return new EE_Select_Multiple_Input($options, $input_args);
241
+
242
+			// text type inputs
243
+			case Text::TYPE_TEXTAREA:
244
+			case Text::TYPE_TEXTAREA_HTML:
245
+				return new EE_Text_Area_Input($input_args);
246 246
 
247
-            case Text::TYPE_EMAIL:
248
-                return new EE_Email_Input($input_args);
247
+			case Text::TYPE_EMAIL:
248
+				return new EE_Email_Input($input_args);
249 249
 
250
-            case Text::TYPE_EMAIL_CONFIRMATION:
251
-                return new EE_Email_Confirm_Input($input_args);
250
+			case Text::TYPE_EMAIL_CONFIRMATION:
251
+				return new EE_Email_Confirm_Input($input_args);
252 252
 
253
-            case Text::TYPE_TEXT:
254
-            default:
255
-                return new EE_Text_Input($input_args);
256
-        }
257
-    }
253
+			case Text::TYPE_TEXT:
254
+			default:
255
+				return new EE_Text_Input($input_args);
256
+		}
257
+	}
258 258
 }
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
             100,
70 70
             $this
71 71
         );
72
-        $this->config->year_input->end_range   = (int) apply_filters(
72
+        $this->config->year_input->end_range = (int) apply_filters(
73 73
             'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__end_range',
74 74
             100,
75 75
             $this
Please login to merge, or discard this patch.
core/domain/services/registration/form/v2/RegistrantFormSection.php 2 patches
Indentation   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -18,175 +18,175 @@
 block discarded – undo
18 18
 class RegistrantFormSection extends EE_Form_Section_Proper
19 19
 {
20 20
 
21
-    /**
22
-     * @var RegistrantFormInput
23
-     */
24
-    public $reg_form_input;
21
+	/**
22
+	 * @var RegistrantFormInput
23
+	 */
24
+	public $reg_form_input;
25 25
 
26 26
 
27
-    /**
28
-     * RegistrantFormSection constructor.
29
-     *
30
-     * @param EE_Registration     $registration
31
-     * @param EE_Form_Section     $form_section
32
-     * @param bool                $admin_request
33
-     * @param RegistrantFormInput $reg_form_input
34
-     * @throws EE_Error
35
-     * @throws ReflectionException
36
-     */
37
-    public function __construct(
38
-        EE_Registration $registration,
39
-        EE_Form_Section $form_section,
40
-        bool $admin_request,
41
-        RegistrantFormInput $reg_form_input
42
-    ) {
43
-        $this->reg_form_input = $reg_form_input;
44
-        parent::__construct($this->generateFormArgs($registration, $form_section, $admin_request));
45
-    }
27
+	/**
28
+	 * RegistrantFormSection constructor.
29
+	 *
30
+	 * @param EE_Registration     $registration
31
+	 * @param EE_Form_Section     $form_section
32
+	 * @param bool                $admin_request
33
+	 * @param RegistrantFormInput $reg_form_input
34
+	 * @throws EE_Error
35
+	 * @throws ReflectionException
36
+	 */
37
+	public function __construct(
38
+		EE_Registration $registration,
39
+		EE_Form_Section $form_section,
40
+		bool $admin_request,
41
+		RegistrantFormInput $reg_form_input
42
+	) {
43
+		$this->reg_form_input = $reg_form_input;
44
+		parent::__construct($this->generateFormArgs($registration, $form_section, $admin_request));
45
+	}
46 46
 
47 47
 
48
-    /**
49
-     * @param EE_Registration $registration
50
-     * @param EE_Form_Section $form_section
51
-     * @param bool            $admin_request
52
-     * @return array
53
-     * @throws EE_Error
54
-     * @throws ReflectionException
55
-     */
56
-    private function generateFormArgs(
57
-        EE_Registration $registration,
58
-        EE_Form_Section $form_section,
59
-        bool $admin_request
60
-    ): array {
61
-        $form_args   = $this->generateTopLevelFormArgs($registration, $form_section, $admin_request);
62
-        $form_inputs = $form_section->formElements();
63
-        // loop thru questions
64
-        foreach ($form_inputs as $form_input) {
65
-            if ($form_input instanceof EE_Form_Element) {
66
-                $form_args['subsections'][ $form_input->slug() ] = $this->reg_form_input->generateFormInput(
67
-                    $registration,
68
-                    $form_section,
69
-                    $form_input
70
-                );
71
-            }
72
-        }
73
-        $form_args['subsections'] = $this->filterFormSectionContent(
74
-            $registration,
75
-            $form_section,
76
-            $form_args['subsections']
77
-        );
78
-        return $form_args;
79
-    }
48
+	/**
49
+	 * @param EE_Registration $registration
50
+	 * @param EE_Form_Section $form_section
51
+	 * @param bool            $admin_request
52
+	 * @return array
53
+	 * @throws EE_Error
54
+	 * @throws ReflectionException
55
+	 */
56
+	private function generateFormArgs(
57
+		EE_Registration $registration,
58
+		EE_Form_Section $form_section,
59
+		bool $admin_request
60
+	): array {
61
+		$form_args   = $this->generateTopLevelFormArgs($registration, $form_section, $admin_request);
62
+		$form_inputs = $form_section->formElements();
63
+		// loop thru questions
64
+		foreach ($form_inputs as $form_input) {
65
+			if ($form_input instanceof EE_Form_Element) {
66
+				$form_args['subsections'][ $form_input->slug() ] = $this->reg_form_input->generateFormInput(
67
+					$registration,
68
+					$form_section,
69
+					$form_input
70
+				);
71
+			}
72
+		}
73
+		$form_args['subsections'] = $this->filterFormSectionContent(
74
+			$registration,
75
+			$form_section,
76
+			$form_args['subsections']
77
+		);
78
+		return $form_args;
79
+	}
80 80
 
81 81
 
82
-    /**
83
-     * @param EE_Registration $registration
84
-     * @param EE_Form_Section $form_section
85
-     * @param bool            $admin_request
86
-     * @return array
87
-     * @throws EE_Error
88
-     * @throws ReflectionException
89
-     */
90
-    protected function generateTopLevelFormArgs(
91
-        EE_Registration $registration,
92
-        EE_Form_Section $form_section,
93
-        bool $admin_request
94
-    ): array {
95
-        return [
96
-            'html_id'         => 'ee-reg-form-qstn-grp-' . $form_section->slug() . '-' . $registration->ID(),
97
-            'html_class'      => $admin_request
98
-                ? 'form-table ee-reg-form-qstn-grp-dv'
99
-                : 'ee-reg-form-qstn-grp-dv',
100
-            'html_label_id'   => 'ee-reg-form-qstn-grp-' . $form_section->slug() . '-' . $registration->ID() . '-lbl',
101
-            'subsections'     => [
102
-                'reg_form_qstn_grp_hdr' => $this->formSectionHeader($form_section, $admin_request),
103
-            ],
104
-            'layout_strategy' => $admin_request
105
-                ? new EE_Admin_Two_Column_Layout()
106
-                : new EE_Div_Per_Section_Layout(),
107
-        ];
108
-    }
82
+	/**
83
+	 * @param EE_Registration $registration
84
+	 * @param EE_Form_Section $form_section
85
+	 * @param bool            $admin_request
86
+	 * @return array
87
+	 * @throws EE_Error
88
+	 * @throws ReflectionException
89
+	 */
90
+	protected function generateTopLevelFormArgs(
91
+		EE_Registration $registration,
92
+		EE_Form_Section $form_section,
93
+		bool $admin_request
94
+	): array {
95
+		return [
96
+			'html_id'         => 'ee-reg-form-qstn-grp-' . $form_section->slug() . '-' . $registration->ID(),
97
+			'html_class'      => $admin_request
98
+				? 'form-table ee-reg-form-qstn-grp-dv'
99
+				: 'ee-reg-form-qstn-grp-dv',
100
+			'html_label_id'   => 'ee-reg-form-qstn-grp-' . $form_section->slug() . '-' . $registration->ID() . '-lbl',
101
+			'subsections'     => [
102
+				'reg_form_qstn_grp_hdr' => $this->formSectionHeader($form_section, $admin_request),
103
+			],
104
+			'layout_strategy' => $admin_request
105
+				? new EE_Admin_Two_Column_Layout()
106
+				: new EE_Div_Per_Section_Layout(),
107
+		];
108
+	}
109 109
 
110 110
 
111
-    /**
112
-     * @param EE_Form_Section $form_section
113
-     * @param bool            $admin_request
114
-     * @return EE_Form_Section_HTML
115
-     * @throws EE_Error
116
-     * @throws ReflectionException
117
-     */
118
-    private function formSectionHeader(EE_Form_Section $form_section, bool $admin_request): EE_Form_Section_HTML
119
-    {
120
-        $html  = '';
121
-        $label = $form_section->label();
122
-        // group_name
123
-        if ($label instanceof FormLabel && $label->showLabel()) {
124
-            if ($admin_request && $label->adminLabel() !== '') {
125
-                $html .= EEH_HTML::br();
126
-                $html .= EEH_HTML::h3(
127
-                    $label->adminLabel(),
128
-                    '',
129
-                    'ee-reg-form-qstn-grp-title title',
130
-                    'font-size: 1.3em; padding-left:0;'
131
-                );
132
-            } elseif (! $admin_request && $label->publicLabel() !== '') {
133
-                $html .= EEH_HTML::h4(
134
-                    $label->publicLabel(),
135
-                    '',
136
-                    'ee-reg-form-qstn-grp-title section-title'
137
-                );
138
-            }
139
-        }
140
-        // group_desc
141
-        // if ($question_group->show_group_desc() && $question_group->desc() !== '') {
142
-        //     $html .= EEH_HTML::p(
143
-        //         $question_group->desc(),
144
-        //         '',
145
-        //         $admin_request
146
-        //             ? 'ee-reg-form-qstn-grp-desc-pg'
147
-        //             : 'ee-reg-form-qstn-grp-desc-pg small-text lt-grey-text'
148
-        //     );
149
-        // }
150
-        return new EE_Form_Section_HTML($html);
151
-    }
111
+	/**
112
+	 * @param EE_Form_Section $form_section
113
+	 * @param bool            $admin_request
114
+	 * @return EE_Form_Section_HTML
115
+	 * @throws EE_Error
116
+	 * @throws ReflectionException
117
+	 */
118
+	private function formSectionHeader(EE_Form_Section $form_section, bool $admin_request): EE_Form_Section_HTML
119
+	{
120
+		$html  = '';
121
+		$label = $form_section->label();
122
+		// group_name
123
+		if ($label instanceof FormLabel && $label->showLabel()) {
124
+			if ($admin_request && $label->adminLabel() !== '') {
125
+				$html .= EEH_HTML::br();
126
+				$html .= EEH_HTML::h3(
127
+					$label->adminLabel(),
128
+					'',
129
+					'ee-reg-form-qstn-grp-title title',
130
+					'font-size: 1.3em; padding-left:0;'
131
+				);
132
+			} elseif (! $admin_request && $label->publicLabel() !== '') {
133
+				$html .= EEH_HTML::h4(
134
+					$label->publicLabel(),
135
+					'',
136
+					'ee-reg-form-qstn-grp-title section-title'
137
+				);
138
+			}
139
+		}
140
+		// group_desc
141
+		// if ($question_group->show_group_desc() && $question_group->desc() !== '') {
142
+		//     $html .= EEH_HTML::p(
143
+		//         $question_group->desc(),
144
+		//         '',
145
+		//         $admin_request
146
+		//             ? 'ee-reg-form-qstn-grp-desc-pg'
147
+		//             : 'ee-reg-form-qstn-grp-desc-pg small-text lt-grey-text'
148
+		//     );
149
+		// }
150
+		return new EE_Form_Section_HTML($html);
151
+	}
152 152
 
153 153
 
154
-    /**
155
-     * @param EE_Registration $registration
156
-     * @param EE_Form_Section $form_section
157
-     * @param array           $subsections
158
-     * @return array
159
-     */
160
-    private function filterFormSectionContent(
161
-        EE_Registration $registration,
162
-        EE_Form_Section $form_section,
163
-        array $subsections
164
-    ): array {
165
-        // filter for additional content before questions
166
-        $filtered = (array) apply_filters(
167
-            'FHEE__EventEspresso_core_domain_services_registration_form_v2_RegistrantFormSection__filterFormSectionContent',
168
-            [
169
-                'before_inputs' => '',
170
-                'form_section'  => $subsections,
171
-                'after_inputs'  => '',
172
-            ],
173
-            $registration,
174
-            $form_section,
175
-            $this
176
-        );
154
+	/**
155
+	 * @param EE_Registration $registration
156
+	 * @param EE_Form_Section $form_section
157
+	 * @param array           $subsections
158
+	 * @return array
159
+	 */
160
+	private function filterFormSectionContent(
161
+		EE_Registration $registration,
162
+		EE_Form_Section $form_section,
163
+		array $subsections
164
+	): array {
165
+		// filter for additional content before questions
166
+		$filtered = (array) apply_filters(
167
+			'FHEE__EventEspresso_core_domain_services_registration_form_v2_RegistrantFormSection__filterFormSectionContent',
168
+			[
169
+				'before_inputs' => '',
170
+				'form_section'  => $subsections,
171
+				'after_inputs'  => '',
172
+			],
173
+			$registration,
174
+			$form_section,
175
+			$this
176
+		);
177 177
 
178
-        if (! isset($filtered['form_section'])) {
179
-            throw new RuntimeException(
180
-                esc_html__('Form Section arguments can not be removed.', 'event_espresso')
181
-            );
182
-        }
183
-        $form_args = $filtered['form_section'];
184
-        if (! empty($filtered['before_inputs'])) {
185
-            $form_args['reg_form_questions_before'] = new EE_Form_Section_HTML($filtered['before_inputs']);
186
-        }
187
-        if (! empty($filtered['after_inputs'])) {
188
-            $form_args['reg_form_questions_after'] = new EE_Form_Section_HTML($filtered['after_inputs']);
189
-        }
190
-        return $form_args;
191
-    }
178
+		if (! isset($filtered['form_section'])) {
179
+			throw new RuntimeException(
180
+				esc_html__('Form Section arguments can not be removed.', 'event_espresso')
181
+			);
182
+		}
183
+		$form_args = $filtered['form_section'];
184
+		if (! empty($filtered['before_inputs'])) {
185
+			$form_args['reg_form_questions_before'] = new EE_Form_Section_HTML($filtered['before_inputs']);
186
+		}
187
+		if (! empty($filtered['after_inputs'])) {
188
+			$form_args['reg_form_questions_after'] = new EE_Form_Section_HTML($filtered['after_inputs']);
189
+		}
190
+		return $form_args;
191
+	}
192 192
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
         // loop thru questions
64 64
         foreach ($form_inputs as $form_input) {
65 65
             if ($form_input instanceof EE_Form_Element) {
66
-                $form_args['subsections'][ $form_input->slug() ] = $this->reg_form_input->generateFormInput(
66
+                $form_args['subsections'][$form_input->slug()] = $this->reg_form_input->generateFormInput(
67 67
                     $registration,
68 68
                     $form_section,
69 69
                     $form_input
@@ -93,11 +93,11 @@  discard block
 block discarded – undo
93 93
         bool $admin_request
94 94
     ): array {
95 95
         return [
96
-            'html_id'         => 'ee-reg-form-qstn-grp-' . $form_section->slug() . '-' . $registration->ID(),
96
+            'html_id'         => 'ee-reg-form-qstn-grp-'.$form_section->slug().'-'.$registration->ID(),
97 97
             'html_class'      => $admin_request
98 98
                 ? 'form-table ee-reg-form-qstn-grp-dv'
99 99
                 : 'ee-reg-form-qstn-grp-dv',
100
-            'html_label_id'   => 'ee-reg-form-qstn-grp-' . $form_section->slug() . '-' . $registration->ID() . '-lbl',
100
+            'html_label_id'   => 'ee-reg-form-qstn-grp-'.$form_section->slug().'-'.$registration->ID().'-lbl',
101 101
             'subsections'     => [
102 102
                 'reg_form_qstn_grp_hdr' => $this->formSectionHeader($form_section, $admin_request),
103 103
             ],
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
                     'ee-reg-form-qstn-grp-title title',
130 130
                     'font-size: 1.3em; padding-left:0;'
131 131
                 );
132
-            } elseif (! $admin_request && $label->publicLabel() !== '') {
132
+            } elseif ( ! $admin_request && $label->publicLabel() !== '') {
133 133
                 $html .= EEH_HTML::h4(
134 134
                     $label->publicLabel(),
135 135
                     '',
@@ -175,16 +175,16 @@  discard block
 block discarded – undo
175 175
             $this
176 176
         );
177 177
 
178
-        if (! isset($filtered['form_section'])) {
178
+        if ( ! isset($filtered['form_section'])) {
179 179
             throw new RuntimeException(
180 180
                 esc_html__('Form Section arguments can not be removed.', 'event_espresso')
181 181
             );
182 182
         }
183 183
         $form_args = $filtered['form_section'];
184
-        if (! empty($filtered['before_inputs'])) {
184
+        if ( ! empty($filtered['before_inputs'])) {
185 185
             $form_args['reg_form_questions_before'] = new EE_Form_Section_HTML($filtered['before_inputs']);
186 186
         }
187
-        if (! empty($filtered['after_inputs'])) {
187
+        if ( ! empty($filtered['after_inputs'])) {
188 188
             $form_args['reg_form_questions_after'] = new EE_Form_Section_HTML($filtered['after_inputs']);
189 189
         }
190 190
         return $form_args;
Please login to merge, or discard this patch.
core/domain/services/registration/form/v2/RegistrantFormInput.php 1 patch
Indentation   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -15,118 +15,118 @@
 block discarded – undo
15 15
 class RegistrantFormInput
16 16
 {
17 17
 
18
-    /**
19
-     * @var callable
20
-     */
21
-    protected $addRequiredQuestion;
18
+	/**
19
+	 * @var callable
20
+	 */
21
+	protected $addRequiredQuestion;
22 22
 
23
-    /**
24
-     * @var JsonDataAPI
25
-     */
26
-    public $form_data_api;
23
+	/**
24
+	 * @var JsonDataAPI
25
+	 */
26
+	public $form_data_api;
27 27
 
28
-    /**
29
-     * @var FormInputFactory
30
-     */
31
-    public $form_input_factory;
28
+	/**
29
+	 * @var FormInputFactory
30
+	 */
31
+	public $form_input_factory;
32 32
 
33
-    /**
34
-     * @var   SystemInputFieldNames
35
-     * @since $VID:$
36
-     */
37
-    protected $system_input_field_names;
33
+	/**
34
+	 * @var   SystemInputFieldNames
35
+	 * @since $VID:$
36
+	 */
37
+	protected $system_input_field_names;
38 38
 
39 39
 
40
-    /**
41
-     * @param callable              $addRequiredQuestion
42
-     * @param JsonDataAPI           $form_data_api
43
-     * @param SystemInputFieldNames $system_input_field_names
44
-     */
45
-    public function __construct(
46
-        callable $addRequiredQuestion,
47
-        JsonDataAPI $form_data_api,
48
-        SystemInputFieldNames $system_input_field_names
49
-    ) {
50
-        $this->addRequiredQuestion      = $addRequiredQuestion;
51
-        $this->form_data_api            = $form_data_api;
52
-        $this->system_input_field_names = $system_input_field_names;
53
-        $this->form_input_factory       = new FormInputFactory(
54
-            new FormInputValidationStrategies(
55
-                new FieldLengthCalculator()
56
-            )
57
-        );
58
-    }
40
+	/**
41
+	 * @param callable              $addRequiredQuestion
42
+	 * @param JsonDataAPI           $form_data_api
43
+	 * @param SystemInputFieldNames $system_input_field_names
44
+	 */
45
+	public function __construct(
46
+		callable $addRequiredQuestion,
47
+		JsonDataAPI $form_data_api,
48
+		SystemInputFieldNames $system_input_field_names
49
+	) {
50
+		$this->addRequiredQuestion      = $addRequiredQuestion;
51
+		$this->form_data_api            = $form_data_api;
52
+		$this->system_input_field_names = $system_input_field_names;
53
+		$this->form_input_factory       = new FormInputFactory(
54
+			new FormInputValidationStrategies(
55
+				new FieldLengthCalculator()
56
+			)
57
+		);
58
+	}
59 59
 
60 60
 
61
-    /**
62
-     * @param EE_Registration $registration
63
-     * @param EE_Form_Section $form_section
64
-     * @param EE_Form_Element $form_input
65
-     * @return EE_Form_Input_Base
66
-     * @throws EE_Error
67
-     * @throws ReflectionException
68
-     */
69
-    public function generateFormInput(
70
-        EE_Registration $registration,
71
-        EE_Form_Section $form_section,
72
-        EE_Form_Element $form_input
73
-    ): EE_Form_Input_Base {
74
-        $callback    = $this->addRequiredQuestion;
75
-        $required    = $form_input->required();
76
-        $is_required = $required instanceof Required ? $required->isRequired() : false;
77
-        $callback($form_input->slug(), $is_required);
78
-        $answer = $this->getAnswer($registration, $form_section, $form_input);
79
-        return $this->form_input_factory->create($registration, $form_input, $answer);
80
-    }
61
+	/**
62
+	 * @param EE_Registration $registration
63
+	 * @param EE_Form_Section $form_section
64
+	 * @param EE_Form_Element $form_input
65
+	 * @return EE_Form_Input_Base
66
+	 * @throws EE_Error
67
+	 * @throws ReflectionException
68
+	 */
69
+	public function generateFormInput(
70
+		EE_Registration $registration,
71
+		EE_Form_Section $form_section,
72
+		EE_Form_Element $form_input
73
+	): EE_Form_Input_Base {
74
+		$callback    = $this->addRequiredQuestion;
75
+		$required    = $form_input->required();
76
+		$is_required = $required instanceof Required ? $required->isRequired() : false;
77
+		$callback($form_input->slug(), $is_required);
78
+		$answer = $this->getAnswer($registration, $form_section, $form_input);
79
+		return $this->form_input_factory->create($registration, $form_input, $answer);
80
+	}
81 81
 
82 82
 
83
-    /**
84
-     * @param EE_Registration $registration
85
-     * @param EE_Form_Section $form_section
86
-     * @param EE_Form_Element $form_input
87
-     * @return string
88
-     * @throws EE_Error
89
-     * @throws ReflectionException
90
-     */
91
-    public function getAnswer(
92
-        EE_Registration $registration,
93
-        EE_Form_Section $form_section,
94
-        EE_Form_Element $form_input
95
-    ): string {
96
-        \EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 2);
97
-        // $input_name = $form_input->slug();
98
-        $path = "{$registration->reg_url_link()}.{$form_section->slug()}.{$form_input->slug()}";
99
-        \EEH_Debug_Tools::printr($path, '$path', __FILE__, __LINE__);
100
-        $answer = $this->form_data_api->get($path);
101
-        \EEH_Debug_Tools::printr($form_input->slug(), '$input_name', __FILE__, __LINE__);
102
-        \EEH_Debug_Tools::printr($answer, '$answer', __FILE__, __LINE__);
103
-        // \EEH_Debug_Tools::printr($this->form_data_api->jsonData(), '$this->form_data_api->jsonData()', __FILE__, __LINE__);
104
-        // if ($this->isAttendeeProperty($form_input) && empty($answer)) {
105
-        //     // if this question was for an attendee detail, then check for that answer
106
-        //     $answer = EEM_Answer::instance()->get_attendee_property_answer_value(
107
-        //         $registration,
108
-        //         $this->system_input_field_names->getInputName($input_name)
109
-        //     );
110
-        // }
111
-        // \EEH_Debug_Tools::printr($answer, '$answer', __FILE__, __LINE__);
112
-        return $answer ?: '';
113
-    }
83
+	/**
84
+	 * @param EE_Registration $registration
85
+	 * @param EE_Form_Section $form_section
86
+	 * @param EE_Form_Element $form_input
87
+	 * @return string
88
+	 * @throws EE_Error
89
+	 * @throws ReflectionException
90
+	 */
91
+	public function getAnswer(
92
+		EE_Registration $registration,
93
+		EE_Form_Section $form_section,
94
+		EE_Form_Element $form_input
95
+	): string {
96
+		\EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 2);
97
+		// $input_name = $form_input->slug();
98
+		$path = "{$registration->reg_url_link()}.{$form_section->slug()}.{$form_input->slug()}";
99
+		\EEH_Debug_Tools::printr($path, '$path', __FILE__, __LINE__);
100
+		$answer = $this->form_data_api->get($path);
101
+		\EEH_Debug_Tools::printr($form_input->slug(), '$input_name', __FILE__, __LINE__);
102
+		\EEH_Debug_Tools::printr($answer, '$answer', __FILE__, __LINE__);
103
+		// \EEH_Debug_Tools::printr($this->form_data_api->jsonData(), '$this->form_data_api->jsonData()', __FILE__, __LINE__);
104
+		// if ($this->isAttendeeProperty($form_input) && empty($answer)) {
105
+		//     // if this question was for an attendee detail, then check for that answer
106
+		//     $answer = EEM_Answer::instance()->get_attendee_property_answer_value(
107
+		//         $registration,
108
+		//         $this->system_input_field_names->getInputName($input_name)
109
+		//     );
110
+		// }
111
+		// \EEH_Debug_Tools::printr($answer, '$answer', __FILE__, __LINE__);
112
+		return $answer ?: '';
113
+	}
114 114
 
115 115
 
116
-    /**
117
-     * @param EE_Form_Element $form_input
118
-     * @return bool
119
-     * @throws EE_Error
120
-     * @throws ReflectionException
121
-     */
122
-    public function isAttendeeProperty(EE_Form_Element $form_input): bool
123
-    {
124
-        $maps_to = $form_input->mapsTo();
125
-        if ($maps_to && strpos($maps_to, 'Attendee.') === 0) {
126
-            $model_and_field = explode('.', $maps_to);
127
-            $field           = array_pop($model_and_field);
128
-            return $this->system_input_field_names->setAttendeeField($field, $form_input->slug());
129
-        }
130
-        return false;
131
-    }
116
+	/**
117
+	 * @param EE_Form_Element $form_input
118
+	 * @return bool
119
+	 * @throws EE_Error
120
+	 * @throws ReflectionException
121
+	 */
122
+	public function isAttendeeProperty(EE_Form_Element $form_input): bool
123
+	{
124
+		$maps_to = $form_input->mapsTo();
125
+		if ($maps_to && strpos($maps_to, 'Attendee.') === 0) {
126
+			$model_and_field = explode('.', $maps_to);
127
+			$field           = array_pop($model_and_field);
128
+			return $this->system_input_field_names->setAttendeeField($field, $form_input->slug());
129
+		}
130
+		return false;
131
+	}
132 132
 }
Please login to merge, or discard this patch.
core/domain/services/registration/form/v2/RegistrantForm.php 2 patches
Indentation   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -15,105 +15,105 @@
 block discarded – undo
15 15
 class RegistrantForm extends BaseRegistrantForm
16 16
 {
17 17
 
18
-    /**
19
-     * @var EEM_Form_Element
20
-     */
21
-    protected $form_input_model;
18
+	/**
19
+	 * @var EEM_Form_Element
20
+	 */
21
+	protected $form_input_model;
22 22
 
23
-    /**
24
-     * @var EEM_Form_Section
25
-     */
26
-    public $form_section_model;
23
+	/**
24
+	 * @var EEM_Form_Section
25
+	 */
26
+	public $form_section_model;
27 27
 
28
-    /**
29
-     * @var RegistrantFormInput
30
-     */
31
-    public $reg_form_input_factory;
28
+	/**
29
+	 * @var RegistrantFormInput
30
+	 */
31
+	public $reg_form_input_factory;
32 32
 
33 33
 
34
-    /**
35
-     * RegistrantForm constructor.
36
-     *
37
-     * @param EE_Registration     $registration
38
-     * @param bool                $admin_request
39
-     * @param bool                $copy_attendee_info
40
-     * @param callable            $enablePrintCopyInfo
41
-     * @param RegistrantFormInput $reg_form_input_factory
42
-     * @param EEM_Form_Element    $form_input_model
43
-     * @param EEM_Form_Section    $form_section_model
44
-     * @throws EE_Error
45
-     * @throws ReflectionException
46
-     */
47
-    public function __construct(
48
-        EE_Registration $registration,
49
-        bool $admin_request,
50
-        bool $copy_attendee_info,
51
-        callable $enablePrintCopyInfo,
52
-        RegistrantFormInput $reg_form_input_factory,
53
-        EEM_Form_Element $form_input_model,
54
-        EEM_Form_Section $form_section_model
55
-    ) {
56
-        $this->reg_form_input_factory = $reg_form_input_factory;
57
-        $this->form_input_model       = $form_input_model;
58
-        $this->form_section_model     = $form_section_model;
59
-        parent::__construct(
60
-            $this->generateFormArgs($registration, $admin_request, $copy_attendee_info, $enablePrintCopyInfo)
61
-        );
62
-    }
34
+	/**
35
+	 * RegistrantForm constructor.
36
+	 *
37
+	 * @param EE_Registration     $registration
38
+	 * @param bool                $admin_request
39
+	 * @param bool                $copy_attendee_info
40
+	 * @param callable            $enablePrintCopyInfo
41
+	 * @param RegistrantFormInput $reg_form_input_factory
42
+	 * @param EEM_Form_Element    $form_input_model
43
+	 * @param EEM_Form_Section    $form_section_model
44
+	 * @throws EE_Error
45
+	 * @throws ReflectionException
46
+	 */
47
+	public function __construct(
48
+		EE_Registration $registration,
49
+		bool $admin_request,
50
+		bool $copy_attendee_info,
51
+		callable $enablePrintCopyInfo,
52
+		RegistrantFormInput $reg_form_input_factory,
53
+		EEM_Form_Element $form_input_model,
54
+		EEM_Form_Section $form_section_model
55
+	) {
56
+		$this->reg_form_input_factory = $reg_form_input_factory;
57
+		$this->form_input_model       = $form_input_model;
58
+		$this->form_section_model     = $form_section_model;
59
+		parent::__construct(
60
+			$this->generateFormArgs($registration, $admin_request, $copy_attendee_info, $enablePrintCopyInfo)
61
+		);
62
+	}
63 63
 
64 64
 
65
-    /**
66
-     * @param EE_Registration $registration
67
-     * @param bool            $admin_request
68
-     * @param bool            $copy_attendee_info
69
-     * @param callable        $enablePrintCopyInfo
70
-     * @return array
71
-     * @throws EE_Error
72
-     * @throws ReflectionException
73
-     */
74
-    private function generateFormArgs(
75
-        EE_Registration $registration,
76
-        bool $admin_request,
77
-        bool $copy_attendee_info,
78
-        callable $enablePrintCopyInfo
79
-    ): array {
80
-        static $attendee_nmbr = 1;
81
-        $this->form_args = [];
82
-        // verify that registration has valid event
83
-        if ($registration->event() instanceof EE_Event) {
84
-            $form_sections = $this->form_section_model->getFormSectionsForEvent($registration->event());
85
-            if ($form_sections) {
86
-                $all_form_inputs = $this->form_input_model->getAllFormElementsForFormSections($form_sections);
87
-                // array of params to pass to parent constructor
88
-                $this->form_args = $this->generateTopLevelFormArgs($registration, $admin_request, $attendee_nmbr);
89
-                foreach ($form_sections as $form_section) {
90
-                    if ($form_section instanceof EE_Form_Section) {
91
-                        // \EEH_Debug_Tools::printr($form_section->slug(), '$form_section->slug()', __FILE__, __LINE__);
92
-                        $form_inputs = $form_section->filterFormElements($all_form_inputs);
93
-                        if (empty($form_inputs)) {
94
-                            continue;
95
-                        }
96
-                        $form_section->setFormElements($form_inputs);
97
-                        $registrant_form_section                                 = LoaderFactory::getNew(
98
-                            RegistrantFormSection::class,
99
-                            [$registration, $form_section, $admin_request, $this->reg_form_input_factory]
100
-                        );
101
-                        $this->form_args['subsections'][ $form_section->slug() ] = apply_filters(
102
-                            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
103
-                            $registrant_form_section,
104
-                            $registration,
105
-                            $form_section,
106
-                            $this
107
-                        );
108
-                    }
109
-                }
110
-                $this->addAdditionalAttendeeRegInfoInput($registration);
111
-                $this->enablePrintCopyInfo($attendee_nmbr, $copy_attendee_info, $enablePrintCopyInfo);
112
-                $this->addAdditionalPrimaryRegistrantInputs($registration);
113
-            }
114
-        }
115
-        $attendee_nmbr++;
116
-        $this->setHasQuestions();
117
-        return $this->form_args;
118
-    }
65
+	/**
66
+	 * @param EE_Registration $registration
67
+	 * @param bool            $admin_request
68
+	 * @param bool            $copy_attendee_info
69
+	 * @param callable        $enablePrintCopyInfo
70
+	 * @return array
71
+	 * @throws EE_Error
72
+	 * @throws ReflectionException
73
+	 */
74
+	private function generateFormArgs(
75
+		EE_Registration $registration,
76
+		bool $admin_request,
77
+		bool $copy_attendee_info,
78
+		callable $enablePrintCopyInfo
79
+	): array {
80
+		static $attendee_nmbr = 1;
81
+		$this->form_args = [];
82
+		// verify that registration has valid event
83
+		if ($registration->event() instanceof EE_Event) {
84
+			$form_sections = $this->form_section_model->getFormSectionsForEvent($registration->event());
85
+			if ($form_sections) {
86
+				$all_form_inputs = $this->form_input_model->getAllFormElementsForFormSections($form_sections);
87
+				// array of params to pass to parent constructor
88
+				$this->form_args = $this->generateTopLevelFormArgs($registration, $admin_request, $attendee_nmbr);
89
+				foreach ($form_sections as $form_section) {
90
+					if ($form_section instanceof EE_Form_Section) {
91
+						// \EEH_Debug_Tools::printr($form_section->slug(), '$form_section->slug()', __FILE__, __LINE__);
92
+						$form_inputs = $form_section->filterFormElements($all_form_inputs);
93
+						if (empty($form_inputs)) {
94
+							continue;
95
+						}
96
+						$form_section->setFormElements($form_inputs);
97
+						$registrant_form_section                                 = LoaderFactory::getNew(
98
+							RegistrantFormSection::class,
99
+							[$registration, $form_section, $admin_request, $this->reg_form_input_factory]
100
+						);
101
+						$this->form_args['subsections'][ $form_section->slug() ] = apply_filters(
102
+							'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
103
+							$registrant_form_section,
104
+							$registration,
105
+							$form_section,
106
+							$this
107
+						);
108
+					}
109
+				}
110
+				$this->addAdditionalAttendeeRegInfoInput($registration);
111
+				$this->enablePrintCopyInfo($attendee_nmbr, $copy_attendee_info, $enablePrintCopyInfo);
112
+				$this->addAdditionalPrimaryRegistrantInputs($registration);
113
+			}
114
+		}
115
+		$attendee_nmbr++;
116
+		$this->setHasQuestions();
117
+		return $this->form_args;
118
+	}
119 119
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -94,11 +94,11 @@
 block discarded – undo
94 94
                             continue;
95 95
                         }
96 96
                         $form_section->setFormElements($form_inputs);
97
-                        $registrant_form_section                                 = LoaderFactory::getNew(
97
+                        $registrant_form_section = LoaderFactory::getNew(
98 98
                             RegistrantFormSection::class,
99 99
                             [$registration, $form_section, $admin_request, $this->reg_form_input_factory]
100 100
                         );
101
-                        $this->form_args['subsections'][ $form_section->slug() ] = apply_filters(
101
+                        $this->form_args['subsections'][$form_section->slug()] = apply_filters(
102 102
                             'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
103 103
                             $registrant_form_section,
104 104
                             $registration,
Please login to merge, or discard this patch.
core/domain/services/registration/form/v2/FieldLengthCalculator.php 2 patches
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -17,103 +17,103 @@
 block discarded – undo
17 17
 class FieldLengthCalculator
18 18
 {
19 19
 
20
-    /**
21
-     * @var array
22
-     */
23
-    private $max_field_lengths
24
-        = [
25
-            'Attendee.fname'         => 45,
26
-            'Attendee.lname'         => 45,
27
-            'Attendee.email'         => 255,
28
-            'Attendee.email_confirm' => 255,
29
-            'Attendee.address'       => 255,
30
-            'Attendee.address2'      => 255,
31
-            'Attendee.city'          => 45,
32
-            'Attendee.zip'           => 12,
33
-            'Attendee.phone'         => 45,
34
-        ];
35
-
36
-    /**
37
-     * @var array
38
-     */
39
-    private $min_field_lengths
40
-        = [
41
-            'Attendee.fname'         => 2,
42
-            'Attendee.lname'         => 2,
43
-            'Attendee.email'         => 8,
44
-            'Attendee.email_confirm' => 8,
45
-            'Attendee.zip'           => 4,
46
-            'Attendee.phone'         => 4,
47
-        ];
48
-
49
-
50
-    /**
51
-     * Returns an array where keys are Model + Field names in dot notation; ex: Attendee.email,
52
-     * and values are the highest question max the admin can set on the question
53
-     * (aka the "max max"; eg, a site admin can change the zip question to have a max
54
-     * of 5, but no larger than 12)
55
-     *
56
-     * @return array
57
-     */
58
-    public function maxFieldLengths(): array
59
-    {
60
-        return $this->max_field_lengths;
61
-    }
62
-
63
-
64
-    /**
65
-     * @return array
66
-     */
67
-    public function minFieldLengths(): array
68
-    {
69
-        return $this->min_field_lengths;
70
-    }
71
-
72
-
73
-    /**
74
-     * @param string|null $model_field_name
75
-     * @return int|float
76
-     */
77
-    public function getMaxFieldLength(?string $model_field_name)
78
-    {
79
-        return $this->max_field_lengths[ $model_field_name ] ?? EE_INF;
80
-    }
81
-
82
-
83
-    /**
84
-     * @param string|null $model_field_name
85
-     * @return int|float
86
-     */
87
-    public function getMinFieldLength(?string $model_field_name)
88
-    {
89
-        return $this->min_field_lengths[ $model_field_name ] ?? 0;
90
-    }
91
-
92
-
93
-    /**
94
-     * @param EE_Form_Element $form_input
95
-     * @return int|float
96
-     * @throws EE_Error
97
-     * @throws ReflectionException
98
-     */
99
-    public function getMaxFieldLengthForInput(EE_Form_Element $form_input)
100
-    {
101
-        $max_field_length = $this->getMaxFieldLength($form_input->mapsTo());
102
-        $max_input_length = $form_input->getAttribute('max') ?: EE_INF;
103
-        return min($max_field_length, $max_input_length);
104
-    }
105
-
106
-
107
-    /**
108
-     * @param EE_Form_Element $form_input
109
-     * @return int|float
110
-     * @throws EE_Error
111
-     * @throws ReflectionException
112
-     */
113
-    public function getMinFieldLengthForInput(EE_Form_Element $form_input)
114
-    {
115
-        $min_field_length = $this->getMinFieldLength($form_input->mapsTo());
116
-        $min_input_length = $form_input->getAttribute('min') ?: 0;
117
-        return max($min_field_length, $min_input_length);
118
-    }
20
+	/**
21
+	 * @var array
22
+	 */
23
+	private $max_field_lengths
24
+		= [
25
+			'Attendee.fname'         => 45,
26
+			'Attendee.lname'         => 45,
27
+			'Attendee.email'         => 255,
28
+			'Attendee.email_confirm' => 255,
29
+			'Attendee.address'       => 255,
30
+			'Attendee.address2'      => 255,
31
+			'Attendee.city'          => 45,
32
+			'Attendee.zip'           => 12,
33
+			'Attendee.phone'         => 45,
34
+		];
35
+
36
+	/**
37
+	 * @var array
38
+	 */
39
+	private $min_field_lengths
40
+		= [
41
+			'Attendee.fname'         => 2,
42
+			'Attendee.lname'         => 2,
43
+			'Attendee.email'         => 8,
44
+			'Attendee.email_confirm' => 8,
45
+			'Attendee.zip'           => 4,
46
+			'Attendee.phone'         => 4,
47
+		];
48
+
49
+
50
+	/**
51
+	 * Returns an array where keys are Model + Field names in dot notation; ex: Attendee.email,
52
+	 * and values are the highest question max the admin can set on the question
53
+	 * (aka the "max max"; eg, a site admin can change the zip question to have a max
54
+	 * of 5, but no larger than 12)
55
+	 *
56
+	 * @return array
57
+	 */
58
+	public function maxFieldLengths(): array
59
+	{
60
+		return $this->max_field_lengths;
61
+	}
62
+
63
+
64
+	/**
65
+	 * @return array
66
+	 */
67
+	public function minFieldLengths(): array
68
+	{
69
+		return $this->min_field_lengths;
70
+	}
71
+
72
+
73
+	/**
74
+	 * @param string|null $model_field_name
75
+	 * @return int|float
76
+	 */
77
+	public function getMaxFieldLength(?string $model_field_name)
78
+	{
79
+		return $this->max_field_lengths[ $model_field_name ] ?? EE_INF;
80
+	}
81
+
82
+
83
+	/**
84
+	 * @param string|null $model_field_name
85
+	 * @return int|float
86
+	 */
87
+	public function getMinFieldLength(?string $model_field_name)
88
+	{
89
+		return $this->min_field_lengths[ $model_field_name ] ?? 0;
90
+	}
91
+
92
+
93
+	/**
94
+	 * @param EE_Form_Element $form_input
95
+	 * @return int|float
96
+	 * @throws EE_Error
97
+	 * @throws ReflectionException
98
+	 */
99
+	public function getMaxFieldLengthForInput(EE_Form_Element $form_input)
100
+	{
101
+		$max_field_length = $this->getMaxFieldLength($form_input->mapsTo());
102
+		$max_input_length = $form_input->getAttribute('max') ?: EE_INF;
103
+		return min($max_field_length, $max_input_length);
104
+	}
105
+
106
+
107
+	/**
108
+	 * @param EE_Form_Element $form_input
109
+	 * @return int|float
110
+	 * @throws EE_Error
111
+	 * @throws ReflectionException
112
+	 */
113
+	public function getMinFieldLengthForInput(EE_Form_Element $form_input)
114
+	{
115
+		$min_field_length = $this->getMinFieldLength($form_input->mapsTo());
116
+		$min_input_length = $form_input->getAttribute('min') ?: 0;
117
+		return max($min_field_length, $min_input_length);
118
+	}
119 119
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
      */
77 77
     public function getMaxFieldLength(?string $model_field_name)
78 78
     {
79
-        return $this->max_field_lengths[ $model_field_name ] ?? EE_INF;
79
+        return $this->max_field_lengths[$model_field_name] ?? EE_INF;
80 80
     }
81 81
 
82 82
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
      */
87 87
     public function getMinFieldLength(?string $model_field_name)
88 88
     {
89
-        return $this->min_field_lengths[ $model_field_name ] ?? 0;
89
+        return $this->min_field_lengths[$model_field_name] ?? 0;
90 90
     }
91 91
 
92 92
 
Please login to merge, or discard this patch.
core/domain/services/registration/form/v2/SystemInputFieldNames.php 2 patches
Indentation   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -14,106 +14,106 @@
 block discarded – undo
14 14
 class SystemInputFieldNames implements SystemInputFieldNamesInterface
15 15
 {
16 16
 
17
-    /**
18
-     * ATTENDEE_FIELD_* constants are a 'balanced ternary' to simultaneously represent
19
-     * whether the requested field is a property and whether or not it has been set:
20
-     *
21
-     *  ATTENDEE_FIELD_SET (1)      indicates that the field IS an attendee field AND has been set
22
-     *  ATTENDEE_FIELD_NOT_SET (0)  indicates that the field IS an attendee field but has not yet been set
23
-     *  ATTENDEE_FIELD_UNKNOWN (-1) indicates that the field is NOT a known attendee field
24
-     */
25
-    const ATTENDEE_FIELD_SET     = 1;
17
+	/**
18
+	 * ATTENDEE_FIELD_* constants are a 'balanced ternary' to simultaneously represent
19
+	 * whether the requested field is a property and whether or not it has been set:
20
+	 *
21
+	 *  ATTENDEE_FIELD_SET (1)      indicates that the field IS an attendee field AND has been set
22
+	 *  ATTENDEE_FIELD_NOT_SET (0)  indicates that the field IS an attendee field but has not yet been set
23
+	 *  ATTENDEE_FIELD_UNKNOWN (-1) indicates that the field is NOT a known attendee field
24
+	 */
25
+	const ATTENDEE_FIELD_SET     = 1;
26 26
 
27
-    const ATTENDEE_FIELD_NOT_SET = 0;
27
+	const ATTENDEE_FIELD_NOT_SET = 0;
28 28
 
29
-    const ATTENDEE_FIELD_UNKNOWN = -1;
29
+	const ATTENDEE_FIELD_UNKNOWN = -1;
30 30
 
31 31
 
32
-    /**
33
-     * @var array
34
-     */
35
-    private $attendee_fields = [
36
-        'ATT_fname'     => null,
37
-        'ATT_lname'     => null,
38
-        'ATT_email'     => null,
39
-        'email_confirm' => null,
40
-        'ATT_address'   => null,
41
-        'ATT_address2'  => null,
42
-        'ATT_city'      => null,
43
-        'STA_ID'        => null,
44
-        'CNT_ISO'       => null,
45
-        'ATT_zip'       => null,
46
-        'ATT_phone'     => null,
47
-    ];
32
+	/**
33
+	 * @var array
34
+	 */
35
+	private $attendee_fields = [
36
+		'ATT_fname'     => null,
37
+		'ATT_lname'     => null,
38
+		'ATT_email'     => null,
39
+		'email_confirm' => null,
40
+		'ATT_address'   => null,
41
+		'ATT_address2'  => null,
42
+		'ATT_city'      => null,
43
+		'STA_ID'        => null,
44
+		'CNT_ISO'       => null,
45
+		'ATT_zip'       => null,
46
+		'ATT_phone'     => null,
47
+	];
48 48
 
49 49
 
50
-    /**
51
-     * @param string $field
52
-     * @return string
53
-     */
54
-    public function getInputName(string $field): string
55
-    {
56
-        switch ($field) {
57
-            case SystemInputFieldNamesInterface::FIRST_NAME && $this->attendeeFieldIsSet('ATT_fname'):
58
-                return $this->attendee_fields['ATT_fname'];
59
-            case SystemInputFieldNamesInterface::LAST_NAME && $this->attendeeFieldIsSet('ATT_lname'):
60
-                return $this->attendee_fields['ATT_lname'];
61
-            case SystemInputFieldNamesInterface::EMAIL && $this->attendeeFieldIsSet('ATT_email'):
62
-                return $this->attendee_fields['ATT_email'];
63
-            case SystemInputFieldNamesInterface::EMAIL_CONFIRM && $this->attendeeFieldIsSet('email_confirm'):
64
-                return $this->attendee_fields['email_confirm'];
65
-            case SystemInputFieldNamesInterface::ADDRESS && $this->attendeeFieldIsSet('ATT_address'):
66
-                return $this->attendee_fields['ATT_address'];
67
-            case SystemInputFieldNamesInterface::ADDRESS_2 && $this->attendeeFieldIsSet('ATT_address2'):
68
-                return $this->attendee_fields['ATT_address2'];
69
-            case SystemInputFieldNamesInterface::CITY && $this->attendeeFieldIsSet('ATT_city'):
70
-                return $this->attendee_fields['ATT_city'];
71
-            case SystemInputFieldNamesInterface::STATE && $this->attendeeFieldIsSet('STA_ID'):
72
-                return $this->attendee_fields['STA_ID'];
73
-            case SystemInputFieldNamesInterface::COUNTRY && $this->attendeeFieldIsSet('CNT_ISO'):
74
-                return $this->attendee_fields['CNT_ISO'];
75
-            case SystemInputFieldNamesInterface::POSTAL_CODE && $this->attendeeFieldIsSet('ATT_zip'):
76
-                return $this->attendee_fields['ATT_zip'];
77
-            case SystemInputFieldNamesInterface::PHONE && $this->attendeeFieldIsSet('ATT_phone'):
78
-                return $this->attendee_fields['ATT_phone'];
79
-        }
80
-        return $field;
81
-    }
50
+	/**
51
+	 * @param string $field
52
+	 * @return string
53
+	 */
54
+	public function getInputName(string $field): string
55
+	{
56
+		switch ($field) {
57
+			case SystemInputFieldNamesInterface::FIRST_NAME && $this->attendeeFieldIsSet('ATT_fname'):
58
+				return $this->attendee_fields['ATT_fname'];
59
+			case SystemInputFieldNamesInterface::LAST_NAME && $this->attendeeFieldIsSet('ATT_lname'):
60
+				return $this->attendee_fields['ATT_lname'];
61
+			case SystemInputFieldNamesInterface::EMAIL && $this->attendeeFieldIsSet('ATT_email'):
62
+				return $this->attendee_fields['ATT_email'];
63
+			case SystemInputFieldNamesInterface::EMAIL_CONFIRM && $this->attendeeFieldIsSet('email_confirm'):
64
+				return $this->attendee_fields['email_confirm'];
65
+			case SystemInputFieldNamesInterface::ADDRESS && $this->attendeeFieldIsSet('ATT_address'):
66
+				return $this->attendee_fields['ATT_address'];
67
+			case SystemInputFieldNamesInterface::ADDRESS_2 && $this->attendeeFieldIsSet('ATT_address2'):
68
+				return $this->attendee_fields['ATT_address2'];
69
+			case SystemInputFieldNamesInterface::CITY && $this->attendeeFieldIsSet('ATT_city'):
70
+				return $this->attendee_fields['ATT_city'];
71
+			case SystemInputFieldNamesInterface::STATE && $this->attendeeFieldIsSet('STA_ID'):
72
+				return $this->attendee_fields['STA_ID'];
73
+			case SystemInputFieldNamesInterface::COUNTRY && $this->attendeeFieldIsSet('CNT_ISO'):
74
+				return $this->attendee_fields['CNT_ISO'];
75
+			case SystemInputFieldNamesInterface::POSTAL_CODE && $this->attendeeFieldIsSet('ATT_zip'):
76
+				return $this->attendee_fields['ATT_zip'];
77
+			case SystemInputFieldNamesInterface::PHONE && $this->attendeeFieldIsSet('ATT_phone'):
78
+				return $this->attendee_fields['ATT_phone'];
79
+		}
80
+		return $field;
81
+	}
82 82
 
83 83
 
84
-    /**
85
-     * uses a "balanced ternary" to simultaneously represent
86
-     * whether the requested field is a property and whether or not it has been set:
87
-     *
88
-     *   1 indicates that the field IS an attendee field AND has been set
89
-     *   0 indicates that the field IS an attendee field but has not yet been set
90
-     *  -1 indicates that the field is NOT a known attendee field
91
-     *
92
-     * @param string $field
93
-     * @return int
94
-     */
95
-    public function attendeeFieldIsSet(string $field): int
96
-    {
97
-        if (! array_key_exists($field, $this->attendee_fields)) {
98
-            return self::ATTENDEE_FIELD_UNKNOWN;
99
-        }
100
-        return $this->attendee_fields[ $field ] !== null
101
-            ? self::ATTENDEE_FIELD_SET
102
-            : self::ATTENDEE_FIELD_NOT_SET;
103
-    }
84
+	/**
85
+	 * uses a "balanced ternary" to simultaneously represent
86
+	 * whether the requested field is a property and whether or not it has been set:
87
+	 *
88
+	 *   1 indicates that the field IS an attendee field AND has been set
89
+	 *   0 indicates that the field IS an attendee field but has not yet been set
90
+	 *  -1 indicates that the field is NOT a known attendee field
91
+	 *
92
+	 * @param string $field
93
+	 * @return int
94
+	 */
95
+	public function attendeeFieldIsSet(string $field): int
96
+	{
97
+		if (! array_key_exists($field, $this->attendee_fields)) {
98
+			return self::ATTENDEE_FIELD_UNKNOWN;
99
+		}
100
+		return $this->attendee_fields[ $field ] !== null
101
+			? self::ATTENDEE_FIELD_SET
102
+			: self::ATTENDEE_FIELD_NOT_SET;
103
+	}
104 104
 
105 105
 
106
-    /**
107
-     * @param string $field
108
-     * @param string $input_name
109
-     * @return bool
110
-     */
111
-    public function setAttendeeField(string $field, string $input_name): bool
112
-    {
113
-        if ($this->attendeeFieldIsSet($field) === self::ATTENDEE_FIELD_NOT_SET) {
114
-            $this->attendee_fields[ $field ] = $input_name;
115
-            return true;
116
-        }
117
-        return false;
118
-    }
106
+	/**
107
+	 * @param string $field
108
+	 * @param string $input_name
109
+	 * @return bool
110
+	 */
111
+	public function setAttendeeField(string $field, string $input_name): bool
112
+	{
113
+		if ($this->attendeeFieldIsSet($field) === self::ATTENDEE_FIELD_NOT_SET) {
114
+			$this->attendee_fields[ $field ] = $input_name;
115
+			return true;
116
+		}
117
+		return false;
118
+	}
119 119
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -94,10 +94,10 @@  discard block
 block discarded – undo
94 94
      */
95 95
     public function attendeeFieldIsSet(string $field): int
96 96
     {
97
-        if (! array_key_exists($field, $this->attendee_fields)) {
97
+        if ( ! array_key_exists($field, $this->attendee_fields)) {
98 98
             return self::ATTENDEE_FIELD_UNKNOWN;
99 99
         }
100
-        return $this->attendee_fields[ $field ] !== null
100
+        return $this->attendee_fields[$field] !== null
101 101
             ? self::ATTENDEE_FIELD_SET
102 102
             : self::ATTENDEE_FIELD_NOT_SET;
103 103
     }
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
     public function setAttendeeField(string $field, string $input_name): bool
112 112
     {
113 113
         if ($this->attendeeFieldIsSet($field) === self::ATTENDEE_FIELD_NOT_SET) {
114
-            $this->attendee_fields[ $field ] = $input_name;
114
+            $this->attendee_fields[$field] = $input_name;
115 115
             return true;
116 116
         }
117 117
         return false;
Please login to merge, or discard this patch.
core/domain/services/registration/form/v2/FormSubmissionHandler.php 2 patches
Indentation   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -14,114 +14,114 @@
 block discarded – undo
14 14
 class FormSubmissionHandler
15 15
 {
16 16
 
17
-    /**
18
-     * @var EE_Form_Submission
19
-     */
20
-    private $form_submission;
21
-
22
-    /**
23
-     * @var EE_Checkout
24
-     */
25
-    private $checkout;
26
-
27
-
28
-    /**
29
-     * @param EE_Checkout $checkout
30
-     */
31
-    public function __construct(EE_Checkout $checkout)
32
-    {
33
-        $this->checkout = $checkout;
34
-
35
-        add_action(
36
-            'AHEE__EE_Form_Section_Proper__receive_form_submission__end',
37
-            [$this]
38
-        );
39
-        /*
17
+	/**
18
+	 * @var EE_Form_Submission
19
+	 */
20
+	private $form_submission;
21
+
22
+	/**
23
+	 * @var EE_Checkout
24
+	 */
25
+	private $checkout;
26
+
27
+
28
+	/**
29
+	 * @param EE_Checkout $checkout
30
+	 */
31
+	public function __construct(EE_Checkout $checkout)
32
+	{
33
+		$this->checkout = $checkout;
34
+
35
+		add_action(
36
+			'AHEE__EE_Form_Section_Proper__receive_form_submission__end',
37
+			[$this]
38
+		);
39
+		/*
40 40
             $req_data,
41 41
             $this,
42 42
             $validate
43 43
         */
44
-    }
45
-
46
-
47
-    /**
48
-     * @return JsonDataAPI
49
-     * @throws EE_Error
50
-     * @throws ReflectionException
51
-     */
52
-    public function getFormDataAPI(): JsonDataAPI
53
-    {
54
-        $this->getFormSubmission();
55
-        $form_data = $this->form_submission instanceof EE_Form_Submission ? $this->form_submission->data() : '{}';
56
-        return new JsonDataAPI($form_data);
57
-    }
58
-
59
-
60
-    /**
61
-     * @return EE_Form_Submission
62
-     * @throws EE_Error
63
-     * @throws ReflectionException
64
-     */
65
-    public function getFormSubmission(): EE_Form_Submission
66
-    {
67
-        if (! $this->form_submission instanceof EE_Form_Submission) {
68
-            $form_submission = $this->getFormSubmissionForTransaction($this->checkout->transaction);
69
-            if ($form_submission instanceof EE_Form_Submission) {
70
-                $this->setFormSubmission($form_submission);
71
-            }
72
-        }
73
-        \EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 2);
74
-        \EEH_Debug_Tools::printr($this->form_submission->data(), '$this->form_submission->data()', __FILE__, __LINE__);
75
-        return $this->form_submission;
76
-    }
77
-
78
-
79
-    /**
80
-     * @param EE_Transaction $transaction
81
-     * @return EE_Form_Submission|null
82
-     * @throws EE_Error
83
-     * @throws ReflectionException
84
-     */
85
-    public function getFormSubmissionForTransaction(EE_Transaction $transaction): ?EE_Form_Submission
86
-    {
87
-        $form_submission = EEM_Form_Submission::instance()->getFormSubmissionForTransaction($transaction);
88
-        return $form_submission instanceof EE_Form_Submission ? $form_submission : null;
89
-        // if () {
90
-        // }
91
-        // return $this->generateFormSubmission($transaction);
92
-    }
93
-
94
-
95
-    /**
96
-     * @return EE_Form_Submission
97
-     * @throws EE_Error
98
-     * @throws ReflectionException
99
-     */
100
-    public function generateFormSubmission(): EE_Form_Submission
101
-    {
102
-        $TXN_ID = $this->checkout->transaction->ID();
103
-        $form_data = $this->checkout->registration_form->valid_data();
104
-        \EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 2);
105
-        \EEH_Debug_Tools::printr($TXN_ID, '$TXN_ID', __FILE__, __LINE__);
106
-        \EEH_Debug_Tools::printr($form_data, 'form data', __FILE__, __LINE__);
107
-        $form_submission = EE_Form_Submission::new_instance(
108
-            [
109
-                'FSB_UUID' => md5(uniqid($TXN_ID . time(), true)),
110
-                'FSC_UUID' => md5(uniqid($TXN_ID . time(), true)),
111
-                'FSB_data' => $form_data,
112
-                'TXN_ID'   => $TXN_ID,
113
-            ]
114
-        );
115
-        $form_submission->save();
116
-        return $form_submission;
117
-    }
118
-
119
-
120
-    /**
121
-     * @param EE_Form_Submission $form_submission
122
-     */
123
-    private function setFormSubmission(EE_Form_Submission $form_submission): void
124
-    {
125
-        $this->form_submission = $form_submission;
126
-    }
44
+	}
45
+
46
+
47
+	/**
48
+	 * @return JsonDataAPI
49
+	 * @throws EE_Error
50
+	 * @throws ReflectionException
51
+	 */
52
+	public function getFormDataAPI(): JsonDataAPI
53
+	{
54
+		$this->getFormSubmission();
55
+		$form_data = $this->form_submission instanceof EE_Form_Submission ? $this->form_submission->data() : '{}';
56
+		return new JsonDataAPI($form_data);
57
+	}
58
+
59
+
60
+	/**
61
+	 * @return EE_Form_Submission
62
+	 * @throws EE_Error
63
+	 * @throws ReflectionException
64
+	 */
65
+	public function getFormSubmission(): EE_Form_Submission
66
+	{
67
+		if (! $this->form_submission instanceof EE_Form_Submission) {
68
+			$form_submission = $this->getFormSubmissionForTransaction($this->checkout->transaction);
69
+			if ($form_submission instanceof EE_Form_Submission) {
70
+				$this->setFormSubmission($form_submission);
71
+			}
72
+		}
73
+		\EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 2);
74
+		\EEH_Debug_Tools::printr($this->form_submission->data(), '$this->form_submission->data()', __FILE__, __LINE__);
75
+		return $this->form_submission;
76
+	}
77
+
78
+
79
+	/**
80
+	 * @param EE_Transaction $transaction
81
+	 * @return EE_Form_Submission|null
82
+	 * @throws EE_Error
83
+	 * @throws ReflectionException
84
+	 */
85
+	public function getFormSubmissionForTransaction(EE_Transaction $transaction): ?EE_Form_Submission
86
+	{
87
+		$form_submission = EEM_Form_Submission::instance()->getFormSubmissionForTransaction($transaction);
88
+		return $form_submission instanceof EE_Form_Submission ? $form_submission : null;
89
+		// if () {
90
+		// }
91
+		// return $this->generateFormSubmission($transaction);
92
+	}
93
+
94
+
95
+	/**
96
+	 * @return EE_Form_Submission
97
+	 * @throws EE_Error
98
+	 * @throws ReflectionException
99
+	 */
100
+	public function generateFormSubmission(): EE_Form_Submission
101
+	{
102
+		$TXN_ID = $this->checkout->transaction->ID();
103
+		$form_data = $this->checkout->registration_form->valid_data();
104
+		\EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 2);
105
+		\EEH_Debug_Tools::printr($TXN_ID, '$TXN_ID', __FILE__, __LINE__);
106
+		\EEH_Debug_Tools::printr($form_data, 'form data', __FILE__, __LINE__);
107
+		$form_submission = EE_Form_Submission::new_instance(
108
+			[
109
+				'FSB_UUID' => md5(uniqid($TXN_ID . time(), true)),
110
+				'FSC_UUID' => md5(uniqid($TXN_ID . time(), true)),
111
+				'FSB_data' => $form_data,
112
+				'TXN_ID'   => $TXN_ID,
113
+			]
114
+		);
115
+		$form_submission->save();
116
+		return $form_submission;
117
+	}
118
+
119
+
120
+	/**
121
+	 * @param EE_Form_Submission $form_submission
122
+	 */
123
+	private function setFormSubmission(EE_Form_Submission $form_submission): void
124
+	{
125
+		$this->form_submission = $form_submission;
126
+	}
127 127
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
      */
65 65
     public function getFormSubmission(): EE_Form_Submission
66 66
     {
67
-        if (! $this->form_submission instanceof EE_Form_Submission) {
67
+        if ( ! $this->form_submission instanceof EE_Form_Submission) {
68 68
             $form_submission = $this->getFormSubmissionForTransaction($this->checkout->transaction);
69 69
             if ($form_submission instanceof EE_Form_Submission) {
70 70
                 $this->setFormSubmission($form_submission);
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
         \EEH_Debug_Tools::printr($form_data, 'form data', __FILE__, __LINE__);
107 107
         $form_submission = EE_Form_Submission::new_instance(
108 108
             [
109
-                'FSB_UUID' => md5(uniqid($TXN_ID . time(), true)),
110
-                'FSC_UUID' => md5(uniqid($TXN_ID . time(), true)),
109
+                'FSB_UUID' => md5(uniqid($TXN_ID.time(), true)),
110
+                'FSC_UUID' => md5(uniqid($TXN_ID.time(), true)),
111 111
                 'FSB_data' => $form_data,
112 112
                 'TXN_ID'   => $TXN_ID,
113 113
             ]
Please login to merge, or discard this patch.
core/domain/services/registration/form/v2/RegFormDependencyHandler.php 1 patch
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -7,69 +7,69 @@
 block discarded – undo
7 7
 
8 8
 class RegFormDependencyHandler extends DependencyHandler
9 9
 {
10
-    /**
11
-     * @return void
12
-     */
13
-    public function registerDependencies()
14
-    {
15
-        $reg_form_dependencies = [
16
-            'EventEspresso\core\domain\services\registration\form\v2\RegForm'                  => [
17
-                null,
18
-                'FormSubmissionHandler'  => EE_Dependency_Map::load_from_cache,
19
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
20
-            ],
21
-            'EventEspresso\core\domain\services\registration\form\v2\RegistrantForm'           => [
22
-                null,
23
-                null,
24
-                null,
25
-                null,
26
-                'EEM_Form_Element' => EE_Dependency_Map::load_from_cache,
27
-                'EEM_Form_Section' => EE_Dependency_Map::load_from_cache,
28
-            ],
29
-            'EventEspresso\core\domain\services\registration\form\v2\RegistrantFormSection'    => [
30
-                null,
31
-                null,
32
-                null,
33
-                'EventEspresso\core\domain\services\registration\form\v2\RegistrantFormInput' => EE_Dependency_Map::load_from_cache,
34
-            ],
35
-            'EventEspresso\core\domain\services\registration\form\base\CountryOptions'         => [
36
-                null,
37
-                'EEM_Answer'  => EE_Dependency_Map::load_from_cache,
38
-                'EEM_Country' => EE_Dependency_Map::load_from_cache,
39
-            ],
40
-            'EventEspresso\core\domain\services\registration\form\base\StateOptions'           => [
41
-                null,
42
-                'EEM_State' => EE_Dependency_Map::load_from_cache,
43
-            ],
44
-            'EventEspresso\core\domain\services\registration\form\v2\RegFormHandler'           => [
45
-                null,
46
-                'EventEspresso\core\domain\services\registration\form\base\RegistrantData'         => EE_Dependency_Map::load_from_cache,
47
-                'EE_Form_Section_Proper'                                                           => EE_Dependency_Map::load_from_cache,
48
-                'EventEspresso\core\domain\services\registration\form\base\RegFormAttendeeFactory' => EE_Dependency_Map::load_from_cache,
49
-                'EE_Registration_Processor'                                                        => EE_Dependency_Map::load_from_cache,
50
-            ],
51
-            'EventEspresso\core\domain\services\registration\form\v2\RegFormInputHandler'      => [
52
-                null,
53
-                null,
54
-                'EEM_Attendee'                                                                  => EE_Dependency_Map::load_from_cache,
55
-                'EventEspresso\core\domain\services\registration\form\base\RegistrantData'      => EE_Dependency_Map::load_from_cache,
56
-                'EventEspresso\core\domain\services\registration\form\v2\SystemInputFieldNames' => EE_Dependency_Map::load_from_cache,
57
-            ],
58
-            'EventEspresso\core\domain\services\registration\form\base\RegFormAttendeeFactory' => [
59
-                'EventEspresso\core\services\commands\CommandBus'                          => EE_Dependency_Map::load_from_cache,
60
-                'EventEspresso\core\domain\services\registration\form\base\RegistrantData' => EE_Dependency_Map::load_from_cache,
61
-            ],
62
-            'EventEspresso\core\domain\services\registration\form\v2\RegistrantFormInput'      => [
63
-                null,
64
-                null,
65
-                'EventEspresso\core\domain\services\registration\form\v2\SystemInputFieldNames' => EE_Dependency_Map::load_from_cache,
66
-            ],
67
-            'EventEspresso\core\domain\services\registration\form\v2\FormSubmissionHandler'    => [
68
-                'EventEspresso\core\services\request\RequestInterface' => EE_Dependency_Map::load_from_cache,
69
-            ],
70
-        ];
71
-        foreach ($reg_form_dependencies as $class => $dependencies) {
72
-            $this->dependency_map->registerDependencies($class, $dependencies);
73
-        }
74
-    }
10
+	/**
11
+	 * @return void
12
+	 */
13
+	public function registerDependencies()
14
+	{
15
+		$reg_form_dependencies = [
16
+			'EventEspresso\core\domain\services\registration\form\v2\RegForm'                  => [
17
+				null,
18
+				'FormSubmissionHandler'  => EE_Dependency_Map::load_from_cache,
19
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
20
+			],
21
+			'EventEspresso\core\domain\services\registration\form\v2\RegistrantForm'           => [
22
+				null,
23
+				null,
24
+				null,
25
+				null,
26
+				'EEM_Form_Element' => EE_Dependency_Map::load_from_cache,
27
+				'EEM_Form_Section' => EE_Dependency_Map::load_from_cache,
28
+			],
29
+			'EventEspresso\core\domain\services\registration\form\v2\RegistrantFormSection'    => [
30
+				null,
31
+				null,
32
+				null,
33
+				'EventEspresso\core\domain\services\registration\form\v2\RegistrantFormInput' => EE_Dependency_Map::load_from_cache,
34
+			],
35
+			'EventEspresso\core\domain\services\registration\form\base\CountryOptions'         => [
36
+				null,
37
+				'EEM_Answer'  => EE_Dependency_Map::load_from_cache,
38
+				'EEM_Country' => EE_Dependency_Map::load_from_cache,
39
+			],
40
+			'EventEspresso\core\domain\services\registration\form\base\StateOptions'           => [
41
+				null,
42
+				'EEM_State' => EE_Dependency_Map::load_from_cache,
43
+			],
44
+			'EventEspresso\core\domain\services\registration\form\v2\RegFormHandler'           => [
45
+				null,
46
+				'EventEspresso\core\domain\services\registration\form\base\RegistrantData'         => EE_Dependency_Map::load_from_cache,
47
+				'EE_Form_Section_Proper'                                                           => EE_Dependency_Map::load_from_cache,
48
+				'EventEspresso\core\domain\services\registration\form\base\RegFormAttendeeFactory' => EE_Dependency_Map::load_from_cache,
49
+				'EE_Registration_Processor'                                                        => EE_Dependency_Map::load_from_cache,
50
+			],
51
+			'EventEspresso\core\domain\services\registration\form\v2\RegFormInputHandler'      => [
52
+				null,
53
+				null,
54
+				'EEM_Attendee'                                                                  => EE_Dependency_Map::load_from_cache,
55
+				'EventEspresso\core\domain\services\registration\form\base\RegistrantData'      => EE_Dependency_Map::load_from_cache,
56
+				'EventEspresso\core\domain\services\registration\form\v2\SystemInputFieldNames' => EE_Dependency_Map::load_from_cache,
57
+			],
58
+			'EventEspresso\core\domain\services\registration\form\base\RegFormAttendeeFactory' => [
59
+				'EventEspresso\core\services\commands\CommandBus'                          => EE_Dependency_Map::load_from_cache,
60
+				'EventEspresso\core\domain\services\registration\form\base\RegistrantData' => EE_Dependency_Map::load_from_cache,
61
+			],
62
+			'EventEspresso\core\domain\services\registration\form\v2\RegistrantFormInput'      => [
63
+				null,
64
+				null,
65
+				'EventEspresso\core\domain\services\registration\form\v2\SystemInputFieldNames' => EE_Dependency_Map::load_from_cache,
66
+			],
67
+			'EventEspresso\core\domain\services\registration\form\v2\FormSubmissionHandler'    => [
68
+				'EventEspresso\core\services\request\RequestInterface' => EE_Dependency_Map::load_from_cache,
69
+			],
70
+		];
71
+		foreach ($reg_form_dependencies as $class => $dependencies) {
72
+			$this->dependency_map->registerDependencies($class, $dependencies);
73
+		}
74
+	}
75 75
 }
Please login to merge, or discard this patch.