Completed
Branch FET/reg-form-builder/main (0b1bec)
by
unknown
14:36 queued 15s
created
attendee_information/EE_SPCO_Reg_Step_Attendee_Information.class.php 2 patches
Indentation   +468 added lines, -468 removed lines patch added patch discarded remove patch
@@ -22,472 +22,472 @@
 block discarded – undo
22 22
 class EE_SPCO_Reg_Step_Attendee_Information extends EE_SPCO_Reg_Step
23 23
 {
24 24
 
25
-    /**
26
-     * @var RegForm
27
-     */
28
-    public $reg_form;
29
-
30
-    /**
31
-     * @var int
32
-     */
33
-    protected $reg_form_count = 0;
34
-
35
-
36
-    /**
37
-     *    class constructor
38
-     *
39
-     * @access    public
40
-     * @param EE_Checkout $checkout
41
-     */
42
-    public function __construct(EE_Checkout $checkout)
43
-    {
44
-        $this->_slug    = 'attendee_information';
45
-        $this->_name    = esc_html__('Attendee Information', 'event_espresso');
46
-        $this->checkout = $checkout;
47
-        $this->_reset_success_message();
48
-        $this->set_instructions(
49
-            esc_html__('Please answer the following registration questions before proceeding.', 'event_espresso')
50
-        );
51
-    }
52
-
53
-
54
-    public function translate_js_strings()
55
-    {
56
-        EE_Registry::$i18n_js_strings['required_field']            = esc_html__(
57
-            ' is a required question.',
58
-            'event_espresso'
59
-        );
60
-        EE_Registry::$i18n_js_strings['required_multi_field']      = esc_html__(
61
-            ' is a required question. Please enter a value for at least one of the options.',
62
-            'event_espresso'
63
-        );
64
-        EE_Registry::$i18n_js_strings['answer_required_questions'] = esc_html__(
65
-            'Please answer all required questions correctly before proceeding.',
66
-            'event_espresso'
67
-        );
68
-        EE_Registry::$i18n_js_strings['attendee_info_copied']      = sprintf(
69
-            esc_html_x(
70
-                'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.',
71
-                'The attendee information was successfully copied.(line break)Please ensure the rest of the registration form is completed before proceeding.',
72
-                'event_espresso'
73
-            ),
74
-            '<br/>'
75
-        );
76
-        EE_Registry::$i18n_js_strings['attendee_info_copy_error']  = esc_html__(
77
-            'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.',
78
-            'event_espresso'
79
-        );
80
-        EE_Registry::$i18n_js_strings['enter_valid_email']         = esc_html__(
81
-            'You must enter a valid email address.',
82
-            'event_espresso'
83
-        );
84
-        EE_Registry::$i18n_js_strings['valid_email_and_questions'] = esc_html__(
85
-            'You must enter a valid email address and answer all other required questions before you can proceed.',
86
-            'event_espresso'
87
-        );
88
-    }
89
-
90
-
91
-    public function enqueue_styles_and_scripts()
92
-    {
93
-    }
94
-
95
-
96
-    /**
97
-     * @return boolean
98
-     */
99
-    public function initialize_reg_step(): bool
100
-    {
101
-        return true;
102
-    }
103
-
104
-
105
-    /**
106
-     * @return RegForm
107
-     * @throws DomainException
108
-     * @throws InvalidArgumentException
109
-     * @throws EntityNotFoundException
110
-     * @throws InvalidDataTypeException
111
-     * @throws InvalidInterfaceException
112
-     */
113
-    public function generate_reg_form(): RegForm
114
-    {
115
-        /** @var RegFormDependencyHandler $dependency_handler */
116
-        $dependency_handler = LoaderFactory::getShared(RegFormDependencyHandler::class);
117
-        $dependency_handler->registerDependencies();
118
-        // TODO detect if event has a reg form UUID and swap this out for form generated by new reg form builder
119
-        return LoaderFactory::getShared(RegForm::class, [$this]);
120
-    }
121
-
122
-
123
-    /**
124
-     * looking for hooks?
125
-     * this method has been replaced by:
126
-     * EventEspresso\core\domain\services\registration\form\v1\RegForm::getRegForm()
127
-     *
128
-     * @deprecated   $VID:$
129
-     */
130
-    private function _registrations_reg_form()
131
-    {
132
-    }
133
-
134
-
135
-    /**
136
-     * looking for hooks?
137
-     * this method has been replaced by:
138
-     * EventEspresso\core\domain\services\registration\form\v1\RegForm::additionalAttendeeRegInfoInput()
139
-     *
140
-     * @deprecated   $VID:$
141
-     */
142
-    private function _additional_attendee_reg_info_input()
143
-    {
144
-    }
145
-
146
-
147
-    /**
148
-     * looking for hooks?
149
-     * this method has been replaced by:
150
-     * EventEspresso\core\domain\services\registration\form\v1\RegForm::questionGroupRegForm()
151
-     *
152
-     * @deprecated   $VID:$
153
-     */
154
-    private function _question_group_reg_form()
155
-    {
156
-    }
157
-
158
-
159
-    /**
160
-     * looking for hooks?
161
-     * this method has been replaced by:
162
-     * EventEspresso\core\domain\services\registration\form\v1\RegForm::questionGroupHeader()
163
-     *
164
-     * @deprecated   $VID:$
165
-     */
166
-    private function _question_group_header()
167
-    {
168
-    }
169
-
170
-
171
-    /**
172
-     * looking for hooks?
173
-     * this method has been replaced by:
174
-     * EventEspresso\core\domain\services\registration\form\v1\CopyAttendeeInfoForm
175
-     *
176
-     * @deprecated   $VID:$
177
-     */
178
-    private function _copy_attendee_info_form()
179
-    {
180
-    }
181
-
182
-
183
-    /**
184
-     * looking for hooks?
185
-     * this method has been replaced by:
186
-     * EventEspresso\core\domain\services\registration\form\v1\AutoCopyAttendeeInfoForm
187
-     *
188
-     * @deprecated   $VID:$
189
-     */
190
-    private function _auto_copy_attendee_info()
191
-    {
192
-    }
193
-
194
-
195
-    /**
196
-     * looking for hooks?
197
-     * this method has been replaced by:
198
-     * EventEspresso\core\domain\services\registration\form\v1\CopyAttendeeInfoForm
199
-     *
200
-     * @deprecated   $VID:$
201
-     */
202
-    private function _copy_attendee_info_inputs()
203
-    {
204
-    }
205
-
206
-
207
-    /**
208
-     * looking for hooks?
209
-     * this method has been replaced by:
210
-     * EventEspresso\core\domain\services\registration\form\v1\RegForm::additionalPrimaryRegistrantInputs()
211
-     *
212
-     * @deprecated   $VID:$
213
-     */
214
-    private function _additional_primary_registrant_inputs()
215
-    {
216
-    }
217
-
218
-
219
-    /**
220
-     * looking for hooks?
221
-     * this method has been replaced by:
222
-     * EventEspresso\core\domain\services\registration\form\v1\RegFormQuestionFactory::create()
223
-     *
224
-     * @param EE_Registration $registration
225
-     * @param EE_Question     $question
226
-     * @return EE_Form_Input_Base
227
-     * @throws EE_Error
228
-     * @throws ReflectionException
229
-     * @deprecated   $VID:$
230
-     */
231
-    public function reg_form_question(EE_Registration $registration, EE_Question $question): EE_Form_Input_Base
232
-    {
233
-        /** @var RegFormQuestionFactory $reg_form_question_factory */
234
-        $reg_form_question_factory = LoaderFactory::getShared(RegFormQuestionFactory::class);
235
-        return $reg_form_question_factory->create($registration, $question);
236
-    }
237
-
238
-
239
-    /**
240
-     * looking for hooks?
241
-     * this method has been replaced by:
242
-     * EventEspresso\core\domain\services\registration\form\v1\RegForm::generateQuestionInput()
243
-     *
244
-     * @deprecated   $VID:$
245
-     */
246
-    private function _generate_question_input()
247
-    {
248
-    }
249
-
250
-
251
-    /**
252
-     * looking for hooks?
253
-     * this method has been replaced by:
254
-     * EventEspresso\core\domain\services\registration\form\v1\CountryOptions::forLegacyFormInput()
255
-     *
256
-     * @param array|null           $countries_list
257
-     * @param EE_Question|null     $question
258
-     * @param EE_Registration|null $registration
259
-     * @param EE_Answer|null       $answer
260
-     * @return array 2d keys are country IDs, values are their names
261
-     * @throws EE_Error
262
-     * @throws ReflectionException
263
-     * @deprecated   $VID:$
264
-     */
265
-    public function use_cached_countries_for_form_input(
266
-        array $countries_list = null,
267
-        EE_Question $question = null,
268
-        EE_Registration $registration = null,
269
-        EE_Answer $answer = null
270
-    ): array {
271
-        /** @var CountryOptions $country_options */
272
-        $country_options = LoaderFactory::getShared(CountryOptions::class, [$this->checkout->action]);
273
-        return $country_options->forLegacyFormInput($countries_list, $question, $registration, $answer);
274
-    }
275
-
276
-
277
-    /**
278
-     * looking for hooks?
279
-     * this method has been replaced by:
280
-     * EventEspresso\core\domain\services\registration\form\v1\StateOptions::forLegacyFormInput()
281
-     *
282
-     * @param array|null           $states_list
283
-     * @param EE_Question|null     $question
284
-     * @param EE_Registration|null $registration
285
-     * @param EE_Answer|null       $answer
286
-     * @return array 2d keys are state IDs, values are their names
287
-     * @throws EE_Error
288
-     * @throws ReflectionException
289
-     * @deprecated   $VID:$
290
-     */
291
-    public function use_cached_states_for_form_input(
292
-        array $states_list = null,
293
-        EE_Question $question = null,
294
-        EE_Registration $registration = null,
295
-        EE_Answer $answer = null
296
-    ): array {
297
-        /** @var StateOptions $state_options */
298
-        $state_options = LoaderFactory::getShared(StateOptions::class, [$this->checkout->action]);
299
-        return $state_options->forLegacyFormInput($states_list, $question, $registration, $answer);
300
-    }
301
-
302
-
303
-    /********************************************************************************************************/
304
-    /****************************************  PROCESS REG STEP  ****************************************/
305
-    /********************************************************************************************************/
306
-
307
-
308
-    /**
309
-     * @return bool
310
-     * @throws EE_Error
311
-     * @throws InvalidArgumentException
312
-     * @throws ReflectionException
313
-     * @throws RuntimeException
314
-     * @throws InvalidDataTypeException
315
-     * @throws InvalidInterfaceException
316
-     */
317
-    public function process_reg_step(): bool
318
-    {
319
-        // grab validated data from form
320
-        $valid_data = $this->checkout->current_step->valid_data();
321
-        // if we don't have any $valid_data then something went TERRIBLY WRONG !!!
322
-        if (empty($valid_data)) {
323
-            return $this->inValidDataError();
324
-        }
325
-        if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
326
-            return $this->inValidTransactionError();
327
-        }
328
-        // get cached registrations
329
-        $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
330
-        // verify we got the goods
331
-        if (empty($registrations)) {
332
-            return $this->noRegistrationsError();
333
-        }
334
-        /** @var RegFormHandler $reg_form_handler */
335
-        $reg_form_handler = LoaderFactory::getNew(RegFormHandler::class, [$this->checkout]);
336
-        // extract attendee info from form data and save to model objects
337
-        if (! $reg_form_handler->processRegistrations($registrations, $valid_data)) {
338
-            // return immediately if the previous step exited early due to errors
339
-            return false;
340
-        }
341
-        // if first pass thru SPCO,
342
-        // then let's check processed registrations against the total number of tickets in the cart
343
-        $registrations_processed = $reg_form_handler->attendeeCount();
344
-        if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
345
-            return $this->registrationProcessingError($registrations_processed);
346
-        }
347
-        // mark this reg step as completed
348
-        $this->set_completed();
349
-        $this->_set_success_message(
350
-            esc_html__('The Attendee Information Step has been successfully completed.', 'event_espresso')
351
-        );
352
-        // do action in case a plugin wants to do something with the data submitted in step 1.
353
-        // passes EE_Single_Page_Checkout, and it's posted data
354
-        do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data);
355
-        return true;
356
-    }
357
-
358
-
359
-    /**
360
-     * @return bool
361
-     * @since   $VID:$
362
-     */
363
-    private function inValidDataError(): bool
364
-    {
365
-        EE_Error::add_error(
366
-            esc_html__('No valid question responses were received.', 'event_espresso'),
367
-            __FILE__,
368
-            __FUNCTION__,
369
-            __LINE__
370
-        );
371
-        return false;
372
-    }
373
-
374
-
375
-    /**
376
-     * @return bool
377
-     * @since   $VID:$
378
-     */
379
-    private function inValidTransactionError(): bool
380
-    {
381
-        EE_Error::add_error(
382
-            esc_html__(
383
-                'A valid transaction could not be initiated for processing your registrations.',
384
-                'event_espresso'
385
-            ),
386
-            __FILE__,
387
-            __FUNCTION__,
388
-            __LINE__
389
-        );
390
-        return false;
391
-    }
392
-
393
-
394
-    /**
395
-     * @return bool
396
-     * @since   $VID:$
397
-     */
398
-    private function noRegistrationsError(): bool
399
-    {
400
-        // combine the old translated string with a new one, in order to not break translations
401
-        $error_message = esc_html__(
402
-            'Your form data could not be applied to any valid registrations.',
403
-            'event_espresso'
404
-        );
405
-        $error_message .= sprintf(
406
-            esc_html_x(
407
-                '%3$sThis can sometimes happen if too much time has been taken to complete the registration process.%3$sPlease return to the %1$sEvent List%2$s and reselect your tickets. If the problem continues, please contact the site administrator.',
408
-                '(line break)This can sometimes happen if too much time has been taken to complete the registration process.(line break)Please return to the (link)Event List(end link) and reselect your tickets. If the problem continues, please contact the site administrator.',
409
-                'event_espresso'
410
-            ),
411
-            '<a href="' . get_post_type_archive_link('espresso_events') . '" >',
412
-            '</a>',
413
-            '<br />'
414
-        );
415
-        EE_Error::add_error($error_message, __FILE__, __FUNCTION__, __LINE__);
416
-        return false;
417
-    }
418
-
419
-
420
-    /**
421
-     * @param int $registrations_processed
422
-     * @return bool
423
-     * @since   $VID:$
424
-     */
425
-    private function registrationProcessingError(int $registrations_processed): bool
426
-    {
427
-        // generate a correctly translated string for all possible singular/plural combinations
428
-        if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) {
429
-            $error_msg = sprintf(
430
-                esc_html_x(
431
-                    'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed',
432
-                    'There was 1 ticket in the Event Queue, but 2 registrations were processed',
433
-                    'event_espresso'
434
-                ),
435
-                $this->checkout->total_ticket_count,
436
-                $registrations_processed
437
-            );
438
-        } elseif ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) {
439
-            $error_msg = sprintf(
440
-                esc_html_x(
441
-                    'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed',
442
-                    'There was a total of 2 tickets in the Event Queue, but only 1 registration was processed',
443
-                    'event_espresso'
444
-                ),
445
-                $this->checkout->total_ticket_count,
446
-                $registrations_processed
447
-            );
448
-        } else {
449
-            $error_msg = sprintf(
450
-                esc_html__(
451
-                    'There was a total of 2 tickets in the Event Queue, but 2 registrations were processed',
452
-                    'event_espresso'
453
-                ),
454
-                $this->checkout->total_ticket_count,
455
-                $registrations_processed
456
-            );
457
-        }
458
-        EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
459
-        return false;
460
-    }
461
-
462
-
463
-    /**
464
-     *    update_reg_step
465
-     *    this is the final step after a user  revisits the site to edit their attendee information
466
-     *    this gets called AFTER the process_reg_step() method above
467
-     *
468
-     * @return bool
469
-     * @throws EE_Error
470
-     * @throws InvalidArgumentException
471
-     * @throws ReflectionException
472
-     * @throws RuntimeException
473
-     * @throws InvalidDataTypeException
474
-     * @throws InvalidInterfaceException
475
-     */
476
-    public function update_reg_step(): bool
477
-    {
478
-        // save everything
479
-        if ($this->process_reg_step()) {
480
-            $this->checkout->redirect     = true;
481
-            $this->checkout->redirect_url = add_query_arg(
482
-                [
483
-                    'e_reg_url_link' => $this->checkout->reg_url_link,
484
-                    'revisit'        => true,
485
-                ],
486
-                $this->checkout->thank_you_page_url
487
-            );
488
-            $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
489
-            return true;
490
-        }
491
-        return false;
492
-    }
25
+	/**
26
+	 * @var RegForm
27
+	 */
28
+	public $reg_form;
29
+
30
+	/**
31
+	 * @var int
32
+	 */
33
+	protected $reg_form_count = 0;
34
+
35
+
36
+	/**
37
+	 *    class constructor
38
+	 *
39
+	 * @access    public
40
+	 * @param EE_Checkout $checkout
41
+	 */
42
+	public function __construct(EE_Checkout $checkout)
43
+	{
44
+		$this->_slug    = 'attendee_information';
45
+		$this->_name    = esc_html__('Attendee Information', 'event_espresso');
46
+		$this->checkout = $checkout;
47
+		$this->_reset_success_message();
48
+		$this->set_instructions(
49
+			esc_html__('Please answer the following registration questions before proceeding.', 'event_espresso')
50
+		);
51
+	}
52
+
53
+
54
+	public function translate_js_strings()
55
+	{
56
+		EE_Registry::$i18n_js_strings['required_field']            = esc_html__(
57
+			' is a required question.',
58
+			'event_espresso'
59
+		);
60
+		EE_Registry::$i18n_js_strings['required_multi_field']      = esc_html__(
61
+			' is a required question. Please enter a value for at least one of the options.',
62
+			'event_espresso'
63
+		);
64
+		EE_Registry::$i18n_js_strings['answer_required_questions'] = esc_html__(
65
+			'Please answer all required questions correctly before proceeding.',
66
+			'event_espresso'
67
+		);
68
+		EE_Registry::$i18n_js_strings['attendee_info_copied']      = sprintf(
69
+			esc_html_x(
70
+				'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.',
71
+				'The attendee information was successfully copied.(line break)Please ensure the rest of the registration form is completed before proceeding.',
72
+				'event_espresso'
73
+			),
74
+			'<br/>'
75
+		);
76
+		EE_Registry::$i18n_js_strings['attendee_info_copy_error']  = esc_html__(
77
+			'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.',
78
+			'event_espresso'
79
+		);
80
+		EE_Registry::$i18n_js_strings['enter_valid_email']         = esc_html__(
81
+			'You must enter a valid email address.',
82
+			'event_espresso'
83
+		);
84
+		EE_Registry::$i18n_js_strings['valid_email_and_questions'] = esc_html__(
85
+			'You must enter a valid email address and answer all other required questions before you can proceed.',
86
+			'event_espresso'
87
+		);
88
+	}
89
+
90
+
91
+	public function enqueue_styles_and_scripts()
92
+	{
93
+	}
94
+
95
+
96
+	/**
97
+	 * @return boolean
98
+	 */
99
+	public function initialize_reg_step(): bool
100
+	{
101
+		return true;
102
+	}
103
+
104
+
105
+	/**
106
+	 * @return RegForm
107
+	 * @throws DomainException
108
+	 * @throws InvalidArgumentException
109
+	 * @throws EntityNotFoundException
110
+	 * @throws InvalidDataTypeException
111
+	 * @throws InvalidInterfaceException
112
+	 */
113
+	public function generate_reg_form(): RegForm
114
+	{
115
+		/** @var RegFormDependencyHandler $dependency_handler */
116
+		$dependency_handler = LoaderFactory::getShared(RegFormDependencyHandler::class);
117
+		$dependency_handler->registerDependencies();
118
+		// TODO detect if event has a reg form UUID and swap this out for form generated by new reg form builder
119
+		return LoaderFactory::getShared(RegForm::class, [$this]);
120
+	}
121
+
122
+
123
+	/**
124
+	 * looking for hooks?
125
+	 * this method has been replaced by:
126
+	 * EventEspresso\core\domain\services\registration\form\v1\RegForm::getRegForm()
127
+	 *
128
+	 * @deprecated   $VID:$
129
+	 */
130
+	private function _registrations_reg_form()
131
+	{
132
+	}
133
+
134
+
135
+	/**
136
+	 * looking for hooks?
137
+	 * this method has been replaced by:
138
+	 * EventEspresso\core\domain\services\registration\form\v1\RegForm::additionalAttendeeRegInfoInput()
139
+	 *
140
+	 * @deprecated   $VID:$
141
+	 */
142
+	private function _additional_attendee_reg_info_input()
143
+	{
144
+	}
145
+
146
+
147
+	/**
148
+	 * looking for hooks?
149
+	 * this method has been replaced by:
150
+	 * EventEspresso\core\domain\services\registration\form\v1\RegForm::questionGroupRegForm()
151
+	 *
152
+	 * @deprecated   $VID:$
153
+	 */
154
+	private function _question_group_reg_form()
155
+	{
156
+	}
157
+
158
+
159
+	/**
160
+	 * looking for hooks?
161
+	 * this method has been replaced by:
162
+	 * EventEspresso\core\domain\services\registration\form\v1\RegForm::questionGroupHeader()
163
+	 *
164
+	 * @deprecated   $VID:$
165
+	 */
166
+	private function _question_group_header()
167
+	{
168
+	}
169
+
170
+
171
+	/**
172
+	 * looking for hooks?
173
+	 * this method has been replaced by:
174
+	 * EventEspresso\core\domain\services\registration\form\v1\CopyAttendeeInfoForm
175
+	 *
176
+	 * @deprecated   $VID:$
177
+	 */
178
+	private function _copy_attendee_info_form()
179
+	{
180
+	}
181
+
182
+
183
+	/**
184
+	 * looking for hooks?
185
+	 * this method has been replaced by:
186
+	 * EventEspresso\core\domain\services\registration\form\v1\AutoCopyAttendeeInfoForm
187
+	 *
188
+	 * @deprecated   $VID:$
189
+	 */
190
+	private function _auto_copy_attendee_info()
191
+	{
192
+	}
193
+
194
+
195
+	/**
196
+	 * looking for hooks?
197
+	 * this method has been replaced by:
198
+	 * EventEspresso\core\domain\services\registration\form\v1\CopyAttendeeInfoForm
199
+	 *
200
+	 * @deprecated   $VID:$
201
+	 */
202
+	private function _copy_attendee_info_inputs()
203
+	{
204
+	}
205
+
206
+
207
+	/**
208
+	 * looking for hooks?
209
+	 * this method has been replaced by:
210
+	 * EventEspresso\core\domain\services\registration\form\v1\RegForm::additionalPrimaryRegistrantInputs()
211
+	 *
212
+	 * @deprecated   $VID:$
213
+	 */
214
+	private function _additional_primary_registrant_inputs()
215
+	{
216
+	}
217
+
218
+
219
+	/**
220
+	 * looking for hooks?
221
+	 * this method has been replaced by:
222
+	 * EventEspresso\core\domain\services\registration\form\v1\RegFormQuestionFactory::create()
223
+	 *
224
+	 * @param EE_Registration $registration
225
+	 * @param EE_Question     $question
226
+	 * @return EE_Form_Input_Base
227
+	 * @throws EE_Error
228
+	 * @throws ReflectionException
229
+	 * @deprecated   $VID:$
230
+	 */
231
+	public function reg_form_question(EE_Registration $registration, EE_Question $question): EE_Form_Input_Base
232
+	{
233
+		/** @var RegFormQuestionFactory $reg_form_question_factory */
234
+		$reg_form_question_factory = LoaderFactory::getShared(RegFormQuestionFactory::class);
235
+		return $reg_form_question_factory->create($registration, $question);
236
+	}
237
+
238
+
239
+	/**
240
+	 * looking for hooks?
241
+	 * this method has been replaced by:
242
+	 * EventEspresso\core\domain\services\registration\form\v1\RegForm::generateQuestionInput()
243
+	 *
244
+	 * @deprecated   $VID:$
245
+	 */
246
+	private function _generate_question_input()
247
+	{
248
+	}
249
+
250
+
251
+	/**
252
+	 * looking for hooks?
253
+	 * this method has been replaced by:
254
+	 * EventEspresso\core\domain\services\registration\form\v1\CountryOptions::forLegacyFormInput()
255
+	 *
256
+	 * @param array|null           $countries_list
257
+	 * @param EE_Question|null     $question
258
+	 * @param EE_Registration|null $registration
259
+	 * @param EE_Answer|null       $answer
260
+	 * @return array 2d keys are country IDs, values are their names
261
+	 * @throws EE_Error
262
+	 * @throws ReflectionException
263
+	 * @deprecated   $VID:$
264
+	 */
265
+	public function use_cached_countries_for_form_input(
266
+		array $countries_list = null,
267
+		EE_Question $question = null,
268
+		EE_Registration $registration = null,
269
+		EE_Answer $answer = null
270
+	): array {
271
+		/** @var CountryOptions $country_options */
272
+		$country_options = LoaderFactory::getShared(CountryOptions::class, [$this->checkout->action]);
273
+		return $country_options->forLegacyFormInput($countries_list, $question, $registration, $answer);
274
+	}
275
+
276
+
277
+	/**
278
+	 * looking for hooks?
279
+	 * this method has been replaced by:
280
+	 * EventEspresso\core\domain\services\registration\form\v1\StateOptions::forLegacyFormInput()
281
+	 *
282
+	 * @param array|null           $states_list
283
+	 * @param EE_Question|null     $question
284
+	 * @param EE_Registration|null $registration
285
+	 * @param EE_Answer|null       $answer
286
+	 * @return array 2d keys are state IDs, values are their names
287
+	 * @throws EE_Error
288
+	 * @throws ReflectionException
289
+	 * @deprecated   $VID:$
290
+	 */
291
+	public function use_cached_states_for_form_input(
292
+		array $states_list = null,
293
+		EE_Question $question = null,
294
+		EE_Registration $registration = null,
295
+		EE_Answer $answer = null
296
+	): array {
297
+		/** @var StateOptions $state_options */
298
+		$state_options = LoaderFactory::getShared(StateOptions::class, [$this->checkout->action]);
299
+		return $state_options->forLegacyFormInput($states_list, $question, $registration, $answer);
300
+	}
301
+
302
+
303
+	/********************************************************************************************************/
304
+	/****************************************  PROCESS REG STEP  ****************************************/
305
+	/********************************************************************************************************/
306
+
307
+
308
+	/**
309
+	 * @return bool
310
+	 * @throws EE_Error
311
+	 * @throws InvalidArgumentException
312
+	 * @throws ReflectionException
313
+	 * @throws RuntimeException
314
+	 * @throws InvalidDataTypeException
315
+	 * @throws InvalidInterfaceException
316
+	 */
317
+	public function process_reg_step(): bool
318
+	{
319
+		// grab validated data from form
320
+		$valid_data = $this->checkout->current_step->valid_data();
321
+		// if we don't have any $valid_data then something went TERRIBLY WRONG !!!
322
+		if (empty($valid_data)) {
323
+			return $this->inValidDataError();
324
+		}
325
+		if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
326
+			return $this->inValidTransactionError();
327
+		}
328
+		// get cached registrations
329
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
330
+		// verify we got the goods
331
+		if (empty($registrations)) {
332
+			return $this->noRegistrationsError();
333
+		}
334
+		/** @var RegFormHandler $reg_form_handler */
335
+		$reg_form_handler = LoaderFactory::getNew(RegFormHandler::class, [$this->checkout]);
336
+		// extract attendee info from form data and save to model objects
337
+		if (! $reg_form_handler->processRegistrations($registrations, $valid_data)) {
338
+			// return immediately if the previous step exited early due to errors
339
+			return false;
340
+		}
341
+		// if first pass thru SPCO,
342
+		// then let's check processed registrations against the total number of tickets in the cart
343
+		$registrations_processed = $reg_form_handler->attendeeCount();
344
+		if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
345
+			return $this->registrationProcessingError($registrations_processed);
346
+		}
347
+		// mark this reg step as completed
348
+		$this->set_completed();
349
+		$this->_set_success_message(
350
+			esc_html__('The Attendee Information Step has been successfully completed.', 'event_espresso')
351
+		);
352
+		// do action in case a plugin wants to do something with the data submitted in step 1.
353
+		// passes EE_Single_Page_Checkout, and it's posted data
354
+		do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data);
355
+		return true;
356
+	}
357
+
358
+
359
+	/**
360
+	 * @return bool
361
+	 * @since   $VID:$
362
+	 */
363
+	private function inValidDataError(): bool
364
+	{
365
+		EE_Error::add_error(
366
+			esc_html__('No valid question responses were received.', 'event_espresso'),
367
+			__FILE__,
368
+			__FUNCTION__,
369
+			__LINE__
370
+		);
371
+		return false;
372
+	}
373
+
374
+
375
+	/**
376
+	 * @return bool
377
+	 * @since   $VID:$
378
+	 */
379
+	private function inValidTransactionError(): bool
380
+	{
381
+		EE_Error::add_error(
382
+			esc_html__(
383
+				'A valid transaction could not be initiated for processing your registrations.',
384
+				'event_espresso'
385
+			),
386
+			__FILE__,
387
+			__FUNCTION__,
388
+			__LINE__
389
+		);
390
+		return false;
391
+	}
392
+
393
+
394
+	/**
395
+	 * @return bool
396
+	 * @since   $VID:$
397
+	 */
398
+	private function noRegistrationsError(): bool
399
+	{
400
+		// combine the old translated string with a new one, in order to not break translations
401
+		$error_message = esc_html__(
402
+			'Your form data could not be applied to any valid registrations.',
403
+			'event_espresso'
404
+		);
405
+		$error_message .= sprintf(
406
+			esc_html_x(
407
+				'%3$sThis can sometimes happen if too much time has been taken to complete the registration process.%3$sPlease return to the %1$sEvent List%2$s and reselect your tickets. If the problem continues, please contact the site administrator.',
408
+				'(line break)This can sometimes happen if too much time has been taken to complete the registration process.(line break)Please return to the (link)Event List(end link) and reselect your tickets. If the problem continues, please contact the site administrator.',
409
+				'event_espresso'
410
+			),
411
+			'<a href="' . get_post_type_archive_link('espresso_events') . '" >',
412
+			'</a>',
413
+			'<br />'
414
+		);
415
+		EE_Error::add_error($error_message, __FILE__, __FUNCTION__, __LINE__);
416
+		return false;
417
+	}
418
+
419
+
420
+	/**
421
+	 * @param int $registrations_processed
422
+	 * @return bool
423
+	 * @since   $VID:$
424
+	 */
425
+	private function registrationProcessingError(int $registrations_processed): bool
426
+	{
427
+		// generate a correctly translated string for all possible singular/plural combinations
428
+		if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) {
429
+			$error_msg = sprintf(
430
+				esc_html_x(
431
+					'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed',
432
+					'There was 1 ticket in the Event Queue, but 2 registrations were processed',
433
+					'event_espresso'
434
+				),
435
+				$this->checkout->total_ticket_count,
436
+				$registrations_processed
437
+			);
438
+		} elseif ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) {
439
+			$error_msg = sprintf(
440
+				esc_html_x(
441
+					'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed',
442
+					'There was a total of 2 tickets in the Event Queue, but only 1 registration was processed',
443
+					'event_espresso'
444
+				),
445
+				$this->checkout->total_ticket_count,
446
+				$registrations_processed
447
+			);
448
+		} else {
449
+			$error_msg = sprintf(
450
+				esc_html__(
451
+					'There was a total of 2 tickets in the Event Queue, but 2 registrations were processed',
452
+					'event_espresso'
453
+				),
454
+				$this->checkout->total_ticket_count,
455
+				$registrations_processed
456
+			);
457
+		}
458
+		EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
459
+		return false;
460
+	}
461
+
462
+
463
+	/**
464
+	 *    update_reg_step
465
+	 *    this is the final step after a user  revisits the site to edit their attendee information
466
+	 *    this gets called AFTER the process_reg_step() method above
467
+	 *
468
+	 * @return bool
469
+	 * @throws EE_Error
470
+	 * @throws InvalidArgumentException
471
+	 * @throws ReflectionException
472
+	 * @throws RuntimeException
473
+	 * @throws InvalidDataTypeException
474
+	 * @throws InvalidInterfaceException
475
+	 */
476
+	public function update_reg_step(): bool
477
+	{
478
+		// save everything
479
+		if ($this->process_reg_step()) {
480
+			$this->checkout->redirect     = true;
481
+			$this->checkout->redirect_url = add_query_arg(
482
+				[
483
+					'e_reg_url_link' => $this->checkout->reg_url_link,
484
+					'revisit'        => true,
485
+				],
486
+				$this->checkout->thank_you_page_url
487
+			);
488
+			$this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
489
+			return true;
490
+		}
491
+		return false;
492
+	}
493 493
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -53,11 +53,11 @@  discard block
 block discarded – undo
53 53
 
54 54
     public function translate_js_strings()
55 55
     {
56
-        EE_Registry::$i18n_js_strings['required_field']            = esc_html__(
56
+        EE_Registry::$i18n_js_strings['required_field'] = esc_html__(
57 57
             ' is a required question.',
58 58
             'event_espresso'
59 59
         );
60
-        EE_Registry::$i18n_js_strings['required_multi_field']      = esc_html__(
60
+        EE_Registry::$i18n_js_strings['required_multi_field'] = esc_html__(
61 61
             ' is a required question. Please enter a value for at least one of the options.',
62 62
             'event_espresso'
63 63
         );
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
             'Please answer all required questions correctly before proceeding.',
66 66
             'event_espresso'
67 67
         );
68
-        EE_Registry::$i18n_js_strings['attendee_info_copied']      = sprintf(
68
+        EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf(
69 69
             esc_html_x(
70 70
                 'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.',
71 71
                 'The attendee information was successfully copied.(line break)Please ensure the rest of the registration form is completed before proceeding.',
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
             ),
74 74
             '<br/>'
75 75
         );
76
-        EE_Registry::$i18n_js_strings['attendee_info_copy_error']  = esc_html__(
76
+        EE_Registry::$i18n_js_strings['attendee_info_copy_error'] = esc_html__(
77 77
             'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.',
78 78
             'event_espresso'
79 79
         );
80
-        EE_Registry::$i18n_js_strings['enter_valid_email']         = esc_html__(
80
+        EE_Registry::$i18n_js_strings['enter_valid_email'] = esc_html__(
81 81
             'You must enter a valid email address.',
82 82
             'event_espresso'
83 83
         );
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
         if (empty($valid_data)) {
323 323
             return $this->inValidDataError();
324 324
         }
325
-        if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
325
+        if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
326 326
             return $this->inValidTransactionError();
327 327
         }
328 328
         // get cached registrations
@@ -334,14 +334,14 @@  discard block
 block discarded – undo
334 334
         /** @var RegFormHandler $reg_form_handler */
335 335
         $reg_form_handler = LoaderFactory::getNew(RegFormHandler::class, [$this->checkout]);
336 336
         // extract attendee info from form data and save to model objects
337
-        if (! $reg_form_handler->processRegistrations($registrations, $valid_data)) {
337
+        if ( ! $reg_form_handler->processRegistrations($registrations, $valid_data)) {
338 338
             // return immediately if the previous step exited early due to errors
339 339
             return false;
340 340
         }
341 341
         // if first pass thru SPCO,
342 342
         // then let's check processed registrations against the total number of tickets in the cart
343 343
         $registrations_processed = $reg_form_handler->attendeeCount();
344
-        if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
344
+        if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
345 345
             return $this->registrationProcessingError($registrations_processed);
346 346
         }
347 347
         // mark this reg step as completed
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
                 '(line break)This can sometimes happen if too much time has been taken to complete the registration process.(line break)Please return to the (link)Event List(end link) and reselect your tickets. If the problem continues, please contact the site administrator.',
409 409
                 'event_espresso'
410 410
             ),
411
-            '<a href="' . get_post_type_archive_link('espresso_events') . '" >',
411
+            '<a href="'.get_post_type_archive_link('espresso_events').'" >',
412 412
             '</a>',
413 413
             '<br />'
414 414
         );
Please login to merge, or discard this patch.
core/domain/services/graphql/inputs/AttendeesConnectionOrderbyInput.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -17,31 +17,31 @@
 block discarded – undo
17 17
 class AttendeesConnectionOrderbyInput extends InputBase
18 18
 {
19 19
 
20
-    /**
21
-     * AttendeesConnectionOrderbyInput constructor.
22
-     */
23
-    public function __construct()
24
-    {
25
-        $this->setName($this->namespace . 'AttendeesConnectionOrderbyInput');
26
-        $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso'));
27
-        parent::__construct();
28
-    }
20
+	/**
21
+	 * AttendeesConnectionOrderbyInput constructor.
22
+	 */
23
+	public function __construct()
24
+	{
25
+		$this->setName($this->namespace . 'AttendeesConnectionOrderbyInput');
26
+		$this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso'));
27
+		parent::__construct();
28
+	}
29 29
 
30 30
 
31
-    /**
32
-     * @return GraphQLFieldInterface[]
33
-     */
34
-    protected function getFields(): array
35
-    {
36
-        return [
37
-            new GraphQLField(
38
-                'field',
39
-                ['non_null' => $this->namespace . 'AttendeesConnectionOrderbyEnum']
40
-            ),
41
-            new GraphQLField(
42
-                'order',
43
-                'OrderEnum'
44
-            ),
45
-        ];
46
-    }
31
+	/**
32
+	 * @return GraphQLFieldInterface[]
33
+	 */
34
+	protected function getFields(): array
35
+	{
36
+		return [
37
+			new GraphQLField(
38
+				'field',
39
+				['non_null' => $this->namespace . 'AttendeesConnectionOrderbyEnum']
40
+			),
41
+			new GraphQLField(
42
+				'order',
43
+				'OrderEnum'
44
+			),
45
+		];
46
+	}
47 47
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/inputs/TicketsConnectionOrderbyInput.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -17,31 +17,31 @@
 block discarded – undo
17 17
 class TicketsConnectionOrderbyInput extends InputBase
18 18
 {
19 19
 
20
-    /**
21
-     * TicketsConnectionOrderbyInput constructor.
22
-     */
23
-    public function __construct()
24
-    {
25
-        $this->setName($this->namespace . 'TicketsConnectionOrderbyInput');
26
-        $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso'));
27
-        parent::__construct();
28
-    }
20
+	/**
21
+	 * TicketsConnectionOrderbyInput constructor.
22
+	 */
23
+	public function __construct()
24
+	{
25
+		$this->setName($this->namespace . 'TicketsConnectionOrderbyInput');
26
+		$this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso'));
27
+		parent::__construct();
28
+	}
29 29
 
30 30
 
31
-    /**
32
-     * @return GraphQLFieldInterface[]
33
-     */
34
-    protected function getFields(): array
35
-    {
36
-        return [
37
-            new GraphQLField(
38
-                'field',
39
-                ['non_null' => $this->namespace . 'TicketsConnectionOrderbyEnum']
40
-            ),
41
-            new GraphQLField(
42
-                'order',
43
-                'OrderEnum'
44
-            ),
45
-        ];
46
-    }
31
+	/**
32
+	 * @return GraphQLFieldInterface[]
33
+	 */
34
+	protected function getFields(): array
35
+	{
36
+		return [
37
+			new GraphQLField(
38
+				'field',
39
+				['non_null' => $this->namespace . 'TicketsConnectionOrderbyEnum']
40
+			),
41
+			new GraphQLField(
42
+				'order',
43
+				'OrderEnum'
44
+			),
45
+		];
46
+	}
47 47
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/inputs/DatetimesConnectionOrderbyInput.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -17,31 +17,31 @@
 block discarded – undo
17 17
 class DatetimesConnectionOrderbyInput extends InputBase
18 18
 {
19 19
 
20
-    /**
21
-     * DatetimesConnectionOrderbyInput constructor.
22
-     */
23
-    public function __construct()
24
-    {
25
-        $this->setName($this->namespace . 'DatetimesConnectionOrderbyInput');
26
-        $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso'));
27
-        parent::__construct();
28
-    }
20
+	/**
21
+	 * DatetimesConnectionOrderbyInput constructor.
22
+	 */
23
+	public function __construct()
24
+	{
25
+		$this->setName($this->namespace . 'DatetimesConnectionOrderbyInput');
26
+		$this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso'));
27
+		parent::__construct();
28
+	}
29 29
 
30 30
 
31
-    /**
32
-     * @return GraphQLFieldInterface[]
33
-     */
34
-    protected function getFields(): array
35
-    {
36
-        return [
37
-            new GraphQLField(
38
-                'field',
39
-                ['non_null' => $this->namespace . 'DatetimesConnectionOrderbyEnum']
40
-            ),
41
-            new GraphQLField(
42
-                'order',
43
-                'OrderEnum'
44
-            ),
45
-        ];
46
-    }
31
+	/**
32
+	 * @return GraphQLFieldInterface[]
33
+	 */
34
+	protected function getFields(): array
35
+	{
36
+		return [
37
+			new GraphQLField(
38
+				'field',
39
+				['non_null' => $this->namespace . 'DatetimesConnectionOrderbyEnum']
40
+			),
41
+			new GraphQLField(
42
+				'order',
43
+				'OrderEnum'
44
+			),
45
+		];
46
+	}
47 47
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/mutators/TicketUpdate.php 2 patches
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -15,68 +15,68 @@
 block discarded – undo
15 15
 class TicketUpdate extends EntityMutator
16 16
 {
17 17
 
18
-    /**
19
-     * Defines the mutation data modification closure.
20
-     *
21
-     * @param EEM_Ticket $model
22
-     * @param Ticket     $type
23
-     * @return callable
24
-     */
25
-    public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type)
26
-    {
27
-        /**
28
-         * Updates an entity.
29
-         *
30
-         * @param array       $input   The input for the mutation
31
-         * @param AppContext  $context The AppContext passed down to all resolvers
32
-         * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
33
-         * @return array
34
-         * @throws EE_Error
35
-         * @throws ReflectionException
36
-         */
37
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
38
-            try {
39
-                /** @var EE_Ticket $entity */
40
-                $entity = EntityMutator::getEntityFromInputData($model, $input);
18
+	/**
19
+	 * Defines the mutation data modification closure.
20
+	 *
21
+	 * @param EEM_Ticket $model
22
+	 * @param Ticket     $type
23
+	 * @return callable
24
+	 */
25
+	public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type)
26
+	{
27
+		/**
28
+		 * Updates an entity.
29
+		 *
30
+		 * @param array       $input   The input for the mutation
31
+		 * @param AppContext  $context The AppContext passed down to all resolvers
32
+		 * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
33
+		 * @return array
34
+		 * @throws EE_Error
35
+		 * @throws ReflectionException
36
+		 */
37
+		return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
38
+			try {
39
+				/** @var EE_Ticket $entity */
40
+				$entity = EntityMutator::getEntityFromInputData($model, $input);
41 41
 
42
-                $datetimes = [];
43
-                $prices = null;
42
+				$datetimes = [];
43
+				$prices = null;
44 44
 
45
-                $args = TicketMutation::prepareFields($input);
45
+				$args = TicketMutation::prepareFields($input);
46 46
 
47
-                if (isset($args['datetimes'])) {
48
-                    $datetimes = $args['datetimes'];
49
-                    unset($args['datetimes']);
50
-                }
51
-                if (array_key_exists('prices', $args)) {
52
-                    $prices = $args['prices'];
53
-                    unset($args['prices']);
54
-                }
47
+				if (isset($args['datetimes'])) {
48
+					$datetimes = $args['datetimes'];
49
+					unset($args['datetimes']);
50
+				}
51
+				if (array_key_exists('prices', $args)) {
52
+					$prices = $args['prices'];
53
+					unset($args['prices']);
54
+				}
55 55
 
56
-                $entity->save($args);
56
+				$entity->save($args);
57 57
 
58
-                if (! empty($datetimes)) {
59
-                    TicketMutation::setRelatedDatetimes($entity, $datetimes);
60
-                }
61
-                // if prices array is passed.
62
-                if (is_array($prices)) {
63
-                    TicketMutation::setRelatedPrices($entity, $prices);
64
-                }
58
+				if (! empty($datetimes)) {
59
+					TicketMutation::setRelatedDatetimes($entity, $datetimes);
60
+				}
61
+				// if prices array is passed.
62
+				if (is_array($prices)) {
63
+					TicketMutation::setRelatedPrices($entity, $prices);
64
+				}
65 65
 
66
-                do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_ticket_update', $entity, $input);
67
-            } catch (Exception $exception) {
68
-                EntityMutator::handleExceptions(
69
-                    $exception,
70
-                    esc_html__(
71
-                        'The ticket could not be deleted because of the following error(s)',
72
-                        'event_espresso'
73
-                    )
74
-                );
75
-            }
66
+				do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_ticket_update', $entity, $input);
67
+			} catch (Exception $exception) {
68
+				EntityMutator::handleExceptions(
69
+					$exception,
70
+					esc_html__(
71
+						'The ticket could not be deleted because of the following error(s)',
72
+						'event_espresso'
73
+					)
74
+				);
75
+			}
76 76
 
77
-            return [
78
-                'id' => $entity->ID(),
79
-            ];
80
-        };
81
-    }
77
+			return [
78
+				'id' => $entity->ID(),
79
+			];
80
+		};
81
+	}
82 82
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
          * @throws EE_Error
35 35
          * @throws ReflectionException
36 36
          */
37
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
37
+        return static function(array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
38 38
             try {
39 39
                 /** @var EE_Ticket $entity */
40 40
                 $entity = EntityMutator::getEntityFromInputData($model, $input);
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
                 $entity->save($args);
57 57
 
58
-                if (! empty($datetimes)) {
58
+                if ( ! empty($datetimes)) {
59 59
                     TicketMutation::setRelatedDatetimes($entity, $datetimes);
60 60
                 }
61 61
                 // if prices array is passed.
Please login to merge, or discard this patch.
core/domain/services/graphql/mutators/DatetimeBulkUpdate.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -8,17 +8,17 @@
 block discarded – undo
8 8
 class DatetimeBulkUpdate extends EntityMutator
9 9
 {
10 10
 
11
-    /**
12
-     * Defines the mutation data modification closure.
13
-     *
14
-     * @param EEM_Datetime $model
15
-     * @param Datetime     $type
16
-     * @return callable
17
-     */
18
-    public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type): callable
19
-    {
20
-        $entityMutator = DatetimeUpdate::mutateAndGetPayload($model, $type);
21
-        $bulkMutator = new BulkEntityMutator($entityMutator);
22
-        return array($bulkMutator, 'updateEntities');
23
-    }
11
+	/**
12
+	 * Defines the mutation data modification closure.
13
+	 *
14
+	 * @param EEM_Datetime $model
15
+	 * @param Datetime     $type
16
+	 * @return callable
17
+	 */
18
+	public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type): callable
19
+	{
20
+		$entityMutator = DatetimeUpdate::mutateAndGetPayload($model, $type);
21
+		$bulkMutator = new BulkEntityMutator($entityMutator);
22
+		return array($bulkMutator, 'updateEntities');
23
+	}
24 24
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/mutators/EventUpdate.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
          * @param ResolveInfo  $info             The ResolveInfo passed down to all resolvers
35 35
          * @return void
36 36
          */
37
-        return static function (
37
+        return static function(
38 38
             int $id,
39 39
             array $input,
40 40
             WP_Post_Type $post_type_object,
Please login to merge, or discard this patch.
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -14,72 +14,72 @@
 block discarded – undo
14 14
 class EventUpdate extends EntityMutator
15 15
 {
16 16
 
17
-    /**
18
-     * Defines the mutation data modification closure.
19
-     *
20
-     * @param EEM_Event $model
21
-     * @param Event     $type
22
-     * @return callable
23
-     */
24
-    public static function mutateFields(EEM_Event $model, Event $type)
25
-    {
26
-        /**
27
-         * Update additional data related to the entity.
28
-         *
29
-         * @param int          $id               The ID of the postObject being mutated
30
-         * @param array        $input            The input for the mutation
31
-         * @param WP_Post_Type $post_type_object The Post Type Object for the type of post being mutated
32
-         * @param string       $mutation_name    The name of the mutation (ex: create, update, delete)
33
-         * @param AppContext   $context          The AppContext passed down to all resolvers
34
-         * @param ResolveInfo  $info             The ResolveInfo passed down to all resolvers
35
-         * @return void
36
-         */
37
-        return static function (
38
-            int $id,
39
-            array $input,
40
-            WP_Post_Type $post_type_object,
41
-            string $mutation_name,
42
-            AppContext $context,
43
-            ResolveInfo $info
44
-        ) use (
45
-            $model,
46
-            $type
47
-        ) {
48
-            try {
49
-                // Make sure we are dealing with the right entity.
50
-                if (
51
-                    ! property_exists($post_type_object, 'graphql_single_name')
52
-                    || $post_type_object->graphql_single_name !== $type->name()
53
-                ) {
54
-                    return;
55
-                }
17
+	/**
18
+	 * Defines the mutation data modification closure.
19
+	 *
20
+	 * @param EEM_Event $model
21
+	 * @param Event     $type
22
+	 * @return callable
23
+	 */
24
+	public static function mutateFields(EEM_Event $model, Event $type)
25
+	{
26
+		/**
27
+		 * Update additional data related to the entity.
28
+		 *
29
+		 * @param int          $id               The ID of the postObject being mutated
30
+		 * @param array        $input            The input for the mutation
31
+		 * @param WP_Post_Type $post_type_object The Post Type Object for the type of post being mutated
32
+		 * @param string       $mutation_name    The name of the mutation (ex: create, update, delete)
33
+		 * @param AppContext   $context          The AppContext passed down to all resolvers
34
+		 * @param ResolveInfo  $info             The ResolveInfo passed down to all resolvers
35
+		 * @return void
36
+		 */
37
+		return static function (
38
+			int $id,
39
+			array $input,
40
+			WP_Post_Type $post_type_object,
41
+			string $mutation_name,
42
+			AppContext $context,
43
+			ResolveInfo $info
44
+		) use (
45
+			$model,
46
+			$type
47
+		) {
48
+			try {
49
+				// Make sure we are dealing with the right entity.
50
+				if (
51
+					! property_exists($post_type_object, 'graphql_single_name')
52
+					|| $post_type_object->graphql_single_name !== $type->name()
53
+				) {
54
+					return;
55
+				}
56 56
 
57
-                /** @var EE_Event $entity */
58
-                $entity = EntityMutator::getEntityFromID($model, $id);
59
-                $args = EventMutation::prepareFields($input);
57
+				/** @var EE_Event $entity */
58
+				$entity = EntityMutator::getEntityFromID($model, $id);
59
+				$args = EventMutation::prepareFields($input);
60 60
 
61
-                if (isset($args['venue'])) {
62
-                    $venue = $args['venue'];
63
-                    unset($args['venue']);
64
-                }
61
+				if (isset($args['venue'])) {
62
+					$venue = $args['venue'];
63
+					unset($args['venue']);
64
+				}
65 65
 
66
-                // Update the entity
67
-                $entity->save($args);
66
+				// Update the entity
67
+				$entity->save($args);
68 68
 
69
-                if (isset($venue)) {
70
-                    EventMutation::setEventVenue($entity, $venue);
71
-                }
69
+				if (isset($venue)) {
70
+					EventMutation::setEventVenue($entity, $venue);
71
+				}
72 72
 
73
-                do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_event_update', $entity, $input);
74
-            } catch (Exception $exception) {
75
-                EntityMutator::handleExceptions(
76
-                    $exception,
77
-                    esc_html__(
78
-                        'The event could not be updated because of the following error(s)',
79
-                        'event_espresso'
80
-                    )
81
-                );
82
-            }
83
-        };
84
-    }
73
+				do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_event_update', $entity, $input);
74
+			} catch (Exception $exception) {
75
+				EntityMutator::handleExceptions(
76
+					$exception,
77
+					esc_html__(
78
+						'The event could not be updated because of the following error(s)',
79
+						'event_espresso'
80
+					)
81
+				);
82
+			}
83
+		};
84
+	}
85 85
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/mutators/DatetimeUpdate.php 2 patches
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -15,59 +15,59 @@
 block discarded – undo
15 15
 class DatetimeUpdate extends EntityMutator
16 16
 {
17 17
 
18
-    /**
19
-     * Defines the mutation data modification closure.
20
-     *
21
-     * @param EEM_Datetime $model
22
-     * @param Datetime     $type
23
-     * @return callable
24
-     */
25
-    public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type)
26
-    {
27
-        /**
28
-         * Updates an entity.
29
-         *
30
-         * @param array       $input   The input for the mutation
31
-         * @param AppContext  $context The AppContext passed down to all resolvers
32
-         * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
33
-         * @return array
34
-         * @throws EE_Error
35
-         * @throws ReflectionException
36
-         */
37
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
38
-            try {
39
-                /** @var EE_Datetime $entity */
40
-                $entity = EntityMutator::getEntityFromInputData($model, $input);
18
+	/**
19
+	 * Defines the mutation data modification closure.
20
+	 *
21
+	 * @param EEM_Datetime $model
22
+	 * @param Datetime     $type
23
+	 * @return callable
24
+	 */
25
+	public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type)
26
+	{
27
+		/**
28
+		 * Updates an entity.
29
+		 *
30
+		 * @param array       $input   The input for the mutation
31
+		 * @param AppContext  $context The AppContext passed down to all resolvers
32
+		 * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
33
+		 * @return array
34
+		 * @throws EE_Error
35
+		 * @throws ReflectionException
36
+		 */
37
+		return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
38
+			try {
39
+				/** @var EE_Datetime $entity */
40
+				$entity = EntityMutator::getEntityFromInputData($model, $input);
41 41
 
42
-                $tickets = [];
43
-                $args = DatetimeMutation::prepareFields($input);
42
+				$tickets = [];
43
+				$args = DatetimeMutation::prepareFields($input);
44 44
 
45
-                if (isset($args['tickets'])) {
46
-                    $tickets = $args['tickets'];
47
-                    unset($args['tickets']);
48
-                }
45
+				if (isset($args['tickets'])) {
46
+					$tickets = $args['tickets'];
47
+					unset($args['tickets']);
48
+				}
49 49
 
50
-                // Update the entity
51
-                $entity->save($args);
50
+				// Update the entity
51
+				$entity->save($args);
52 52
 
53
-                if (! empty($tickets)) {
54
-                    DatetimeMutation::setRelatedTickets($entity, $tickets);
55
-                }
53
+				if (! empty($tickets)) {
54
+					DatetimeMutation::setRelatedTickets($entity, $tickets);
55
+				}
56 56
 
57
-                do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_datetime_update', $entity, $input);
58
-            } catch (Exception $exception) {
59
-                EntityMutator::handleExceptions(
60
-                    $exception,
61
-                    esc_html__(
62
-                        'The datetime could not be updated because of the following error(s)',
63
-                        'event_espresso'
64
-                    )
65
-                );
66
-            }
57
+				do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_datetime_update', $entity, $input);
58
+			} catch (Exception $exception) {
59
+				EntityMutator::handleExceptions(
60
+					$exception,
61
+					esc_html__(
62
+						'The datetime could not be updated because of the following error(s)',
63
+						'event_espresso'
64
+					)
65
+				);
66
+			}
67 67
 
68
-            return [
69
-                'id' => $entity->ID(),
70
-            ];
71
-        };
72
-    }
68
+			return [
69
+				'id' => $entity->ID(),
70
+			];
71
+		};
72
+	}
73 73
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
          * @throws EE_Error
35 35
          * @throws ReflectionException
36 36
          */
37
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
37
+        return static function(array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
38 38
             try {
39 39
                 /** @var EE_Datetime $entity */
40 40
                 $entity = EntityMutator::getEntityFromInputData($model, $input);
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
                 // Update the entity
51 51
                 $entity->save($args);
52 52
 
53
-                if (! empty($tickets)) {
53
+                if ( ! empty($tickets)) {
54 54
                     DatetimeMutation::setRelatedTickets($entity, $tickets);
55 55
                 }
56 56
 
Please login to merge, or discard this patch.
core/domain/services/graphql/mutators/TicketCreate.php 2 patches
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -13,68 +13,68 @@
 block discarded – undo
13 13
 class TicketCreate extends EntityMutator
14 14
 {
15 15
 
16
-    /**
17
-     * Defines the mutation data modification closure.
18
-     *
19
-     * @param EEM_Ticket $model
20
-     * @param Ticket     $type
21
-     * @return callable
22
-     */
23
-    public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type)
24
-    {
25
-        /**
26
-         * Creates an entity.
27
-         *
28
-         * @param array       $input   The input for the mutation
29
-         * @param AppContext  $context The AppContext passed down to all resolvers
30
-         * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
31
-         * @return array
32
-         */
33
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
34
-            $id = null;
35
-            try {
36
-                EntityMutator::checkPermissions($model);
16
+	/**
17
+	 * Defines the mutation data modification closure.
18
+	 *
19
+	 * @param EEM_Ticket $model
20
+	 * @param Ticket     $type
21
+	 * @return callable
22
+	 */
23
+	public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type)
24
+	{
25
+		/**
26
+		 * Creates an entity.
27
+		 *
28
+		 * @param array       $input   The input for the mutation
29
+		 * @param AppContext  $context The AppContext passed down to all resolvers
30
+		 * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
31
+		 * @return array
32
+		 */
33
+		return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
34
+			$id = null;
35
+			try {
36
+				EntityMutator::checkPermissions($model);
37 37
 
38
-                $datetimes = [];
39
-                $prices = [];
38
+				$datetimes = [];
39
+				$prices = [];
40 40
 
41
-                $args = TicketMutation::prepareFields($input);
41
+				$args = TicketMutation::prepareFields($input);
42 42
 
43
-                if (isset($args['datetimes'])) {
44
-                    $datetimes = $args['datetimes'];
45
-                    unset($args['datetimes']);
46
-                }
47
-                if (isset($args['prices'])) {
48
-                    $prices = $args['prices'];
49
-                    unset($args['prices']);
50
-                }
43
+				if (isset($args['datetimes'])) {
44
+					$datetimes = $args['datetimes'];
45
+					unset($args['datetimes']);
46
+				}
47
+				if (isset($args['prices'])) {
48
+					$prices = $args['prices'];
49
+					unset($args['prices']);
50
+				}
51 51
 
52
-                $entity = EE_Ticket::new_instance($args);
53
-                $id = $entity->save();
54
-                EntityMutator::validateResults($id);
52
+				$entity = EE_Ticket::new_instance($args);
53
+				$id = $entity->save();
54
+				EntityMutator::validateResults($id);
55 55
 
56
-                if (! empty($datetimes)) {
57
-                    TicketMutation::setRelatedDatetimes($entity, $datetimes);
58
-                }
59
-                // if prices are passed.
60
-                if (! empty($prices)) {
61
-                    TicketMutation::setRelatedPrices($entity, $prices);
62
-                }
56
+				if (! empty($datetimes)) {
57
+					TicketMutation::setRelatedDatetimes($entity, $datetimes);
58
+				}
59
+				// if prices are passed.
60
+				if (! empty($prices)) {
61
+					TicketMutation::setRelatedPrices($entity, $prices);
62
+				}
63 63
 
64
-                do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_ticket_create', $entity, $input);
65
-            } catch (Exception $exception) {
66
-                EntityMutator::handleExceptions(
67
-                    $exception,
68
-                    esc_html__(
69
-                        'The ticket could not be created because of the following error(s)',
70
-                        'event_espresso'
71
-                    )
72
-                );
73
-            }
64
+				do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_ticket_create', $entity, $input);
65
+			} catch (Exception $exception) {
66
+				EntityMutator::handleExceptions(
67
+					$exception,
68
+					esc_html__(
69
+						'The ticket could not be created because of the following error(s)',
70
+						'event_espresso'
71
+					)
72
+				);
73
+			}
74 74
 
75
-            return [
76
-                'id' => $id,
77
-            ];
78
-        };
79
-    }
75
+			return [
76
+				'id' => $id,
77
+			];
78
+		};
79
+	}
80 80
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
          * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
31 31
          * @return array
32 32
          */
33
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
33
+        return static function(array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
34 34
             $id = null;
35 35
             try {
36 36
                 EntityMutator::checkPermissions($model);
@@ -53,11 +53,11 @@  discard block
 block discarded – undo
53 53
                 $id = $entity->save();
54 54
                 EntityMutator::validateResults($id);
55 55
 
56
-                if (! empty($datetimes)) {
56
+                if ( ! empty($datetimes)) {
57 57
                     TicketMutation::setRelatedDatetimes($entity, $datetimes);
58 58
                 }
59 59
                 // if prices are passed.
60
-                if (! empty($prices)) {
60
+                if ( ! empty($prices)) {
61 61
                     TicketMutation::setRelatedPrices($entity, $prices);
62 62
                 }
63 63
 
Please login to merge, or discard this patch.