Completed
Branch Gutenberg/master (b3a823)
by
unknown
73:52 queued 60:28
created
core/libraries/form_sections/form_handlers/SequentialStepFormManager.php 2 patches
Indentation   +583 added lines, -583 removed lines patch added patch discarded remove patch
@@ -29,587 +29,587 @@
 block discarded – undo
29 29
 abstract class SequentialStepFormManager
30 30
 {
31 31
 
32
-    /**
33
-     * a simplified URL with no form related parameters
34
-     * that will be used to build the form's redirect URLs
35
-     *
36
-     * @var string $base_url
37
-     */
38
-    private $base_url = '';
39
-
40
-    /**
41
-     * the key used for the URL param that denotes the current form step
42
-     * defaults to 'ee-form-step'
43
-     *
44
-     * @var string $form_step_url_key
45
-     */
46
-    private $form_step_url_key = '';
47
-
48
-    /**
49
-     * @var string $default_form_step
50
-     */
51
-    private $default_form_step = '';
52
-
53
-    /**
54
-     * @var string $form_action
55
-     */
56
-    private $form_action;
57
-
58
-    /**
59
-     * value of one of the string constant above
60
-     *
61
-     * @var string $form_config
62
-     */
63
-    private $form_config;
64
-
65
-    /**
66
-     * @var string $progress_step_style
67
-     */
68
-    private $progress_step_style = '';
69
-
70
-    /**
71
-     * @var EE_Request $request
72
-     */
73
-    private $request;
74
-
75
-    /**
76
-     * @var Collection $form_steps
77
-     */
78
-    protected $form_steps;
79
-
80
-    /**
81
-     * @var ProgressStepManager $progress_step_manager
82
-     */
83
-    protected $progress_step_manager;
84
-
85
-
86
-    /**
87
-     * @return Collection|null
88
-     */
89
-    abstract protected function getFormStepsCollection();
90
-
91
-    // phpcs:disable PEAR.Functions.ValidDefaultValue.NotAtEnd
92
-    /**
93
-     * StepsManager constructor
94
-     *
95
-     * @param string     $base_url
96
-     * @param string     $default_form_step
97
-     * @param string     $form_action
98
-     * @param string     $form_config
99
-     * @param EE_Request $request
100
-     * @param string     $progress_step_style
101
-     * @throws InvalidDataTypeException
102
-     * @throws InvalidArgumentException
103
-     */
104
-    public function __construct(
105
-        $base_url,
106
-        $default_form_step,
107
-        $form_action = '',
108
-        $form_config = FormHandler::ADD_FORM_TAGS_AND_SUBMIT,
109
-        $progress_step_style = 'number_bubbles',
110
-        EE_Request $request
111
-    ) {
112
-        $this->setBaseUrl($base_url);
113
-        $this->setDefaultFormStep($default_form_step);
114
-        $this->setFormAction($form_action);
115
-        $this->setFormConfig($form_config);
116
-        $this->setProgressStepStyle($progress_step_style);
117
-        $this->request = $request;
118
-    }
119
-
120
-
121
-    /**
122
-     * @return string
123
-     * @throws InvalidFormHandlerException
124
-     */
125
-    public function baseUrl()
126
-    {
127
-        if (strpos($this->base_url, $this->getCurrentStep()->slug()) === false) {
128
-            add_query_arg(
129
-                array($this->form_step_url_key => $this->getCurrentStep()->slug()),
130
-                $this->base_url
131
-            );
132
-        }
133
-        return $this->base_url;
134
-    }
135
-
136
-
137
-    /**
138
-     * @param string $base_url
139
-     * @throws InvalidDataTypeException
140
-     * @throws InvalidArgumentException
141
-     */
142
-    protected function setBaseUrl($base_url)
143
-    {
144
-        if (! is_string($base_url)) {
145
-            throw new InvalidDataTypeException('$base_url', $base_url, 'string');
146
-        }
147
-        if (empty($base_url)) {
148
-            throw new InvalidArgumentException(
149
-                esc_html__('The base URL can not be an empty string.', 'event_espresso')
150
-            );
151
-        }
152
-        $this->base_url = $base_url;
153
-    }
154
-
155
-
156
-    /**
157
-     * @return string
158
-     * @throws InvalidDataTypeException
159
-     */
160
-    public function formStepUrlKey()
161
-    {
162
-        if (empty($this->form_step_url_key)) {
163
-            $this->setFormStepUrlKey();
164
-        }
165
-        return $this->form_step_url_key;
166
-    }
167
-
168
-
169
-    /**
170
-     * @param string $form_step_url_key
171
-     * @throws InvalidDataTypeException
172
-     */
173
-    public function setFormStepUrlKey($form_step_url_key = 'ee-form-step')
174
-    {
175
-        if (! is_string($form_step_url_key)) {
176
-            throw new InvalidDataTypeException('$form_step_key', $form_step_url_key, 'string');
177
-        }
178
-        $this->form_step_url_key = ! empty($form_step_url_key) ? $form_step_url_key : 'ee-form-step';
179
-    }
180
-
181
-
182
-    /**
183
-     * @return string
184
-     */
185
-    public function defaultFormStep()
186
-    {
187
-        return $this->default_form_step;
188
-    }
189
-
190
-
191
-    /**
192
-     * @param $default_form_step
193
-     * @throws InvalidDataTypeException
194
-     */
195
-    protected function setDefaultFormStep($default_form_step)
196
-    {
197
-        if (! is_string($default_form_step)) {
198
-            throw new InvalidDataTypeException('$default_form_step', $default_form_step, 'string');
199
-        }
200
-        $this->default_form_step = $default_form_step;
201
-    }
202
-
203
-
204
-    /**
205
-     * @return void
206
-     * @throws \EventEspresso\core\exceptions\InvalidIdentifierException
207
-     * @throws InvalidDataTypeException
208
-     */
209
-    protected function setCurrentStepFromRequest()
210
-    {
211
-        $current_step_slug = $this->request()->get($this->formStepUrlKey(), $this->defaultFormStep());
212
-        if (! $this->form_steps->setCurrent($current_step_slug)) {
213
-            throw new InvalidIdentifierException(
214
-                $current_step_slug,
215
-                $this->defaultFormStep(),
216
-                $message = sprintf(
217
-                    esc_html__(
218
-                        'The "%1$s" form step could not be set.',
219
-                        'event_espresso'
220
-                    ),
221
-                    $current_step_slug
222
-                )
223
-            );
224
-        }
225
-    }
226
-
227
-
228
-    /**
229
-     * @return object|SequentialStepFormInterface
230
-     * @throws InvalidFormHandlerException
231
-     */
232
-    public function getCurrentStep()
233
-    {
234
-        if (! $this->form_steps->current() instanceof SequentialStepForm) {
235
-            throw new InvalidFormHandlerException($this->form_steps->current());
236
-        }
237
-        return $this->form_steps->current();
238
-    }
239
-
240
-
241
-    /**
242
-     * @return string
243
-     * @throws InvalidFormHandlerException
244
-     */
245
-    public function formAction()
246
-    {
247
-        if (! is_string($this->form_action) || empty($this->form_action)) {
248
-            $this->form_action = $this->baseUrl();
249
-        }
250
-        return $this->form_action;
251
-    }
252
-
253
-
254
-    /**
255
-     * @param string $form_action
256
-     * @throws InvalidDataTypeException
257
-     */
258
-    public function setFormAction($form_action)
259
-    {
260
-        if (! is_string($form_action)) {
261
-            throw new InvalidDataTypeException('$form_action', $form_action, 'string');
262
-        }
263
-        $this->form_action = $form_action;
264
-    }
265
-
266
-
267
-    /**
268
-     * @param array $form_action_args
269
-     * @throws InvalidDataTypeException
270
-     * @throws InvalidFormHandlerException
271
-     */
272
-    public function addFormActionArgs($form_action_args = array())
273
-    {
274
-        if (! is_array($form_action_args)) {
275
-            throw new InvalidDataTypeException('$form_action_args', $form_action_args, 'array');
276
-        }
277
-        $form_action_args = ! empty($form_action_args)
278
-            ? $form_action_args
279
-            : array($this->formStepUrlKey() => $this->form_steps->current()->slug());
280
-        $this->getCurrentStep()->setFormAction(
281
-            add_query_arg($form_action_args, $this->formAction())
282
-        );
283
-        $this->form_action = $this->getCurrentStep()->formAction();
284
-    }
285
-
286
-
287
-    /**
288
-     * @return string
289
-     */
290
-    public function formConfig()
291
-    {
292
-        return $this->form_config;
293
-    }
294
-
295
-
296
-    /**
297
-     * @param string $form_config
298
-     */
299
-    public function setFormConfig($form_config)
300
-    {
301
-        $this->form_config = $form_config;
302
-    }
303
-
304
-
305
-    /**
306
-     * @return string
307
-     */
308
-    public function progressStepStyle()
309
-    {
310
-        return $this->progress_step_style;
311
-    }
312
-
313
-
314
-    /**
315
-     * @param string $progress_step_style
316
-     */
317
-    public function setProgressStepStyle($progress_step_style)
318
-    {
319
-        $this->progress_step_style = $progress_step_style;
320
-    }
321
-
322
-
323
-    /**
324
-     * @return EE_Request
325
-     */
326
-    public function request()
327
-    {
328
-        return $this->request;
329
-    }
330
-
331
-
332
-    /**
333
-     * @return Collection|null
334
-     * @throws InvalidInterfaceException
335
-     */
336
-    protected function getProgressStepsCollection()
337
-    {
338
-        static $collection = null;
339
-        if (! $collection instanceof ProgressStepCollection) {
340
-            $collection = new ProgressStepCollection();
341
-        }
342
-        return $collection;
343
-    }
344
-
345
-
346
-    /**
347
-     * @param Collection $progress_steps_collection
348
-     * @return ProgressStepManager
349
-     * @throws InvalidInterfaceException
350
-     * @throws InvalidClassException
351
-     * @throws InvalidDataTypeException
352
-     * @throws InvalidEntityException
353
-     * @throws InvalidFormHandlerException
354
-     */
355
-    protected function generateProgressSteps(Collection $progress_steps_collection)
356
-    {
357
-        $current_step = $this->getCurrentStep();
358
-        /** @var SequentialStepForm $form_step */
359
-        foreach ($this->form_steps as $form_step) {
360
-            // is this step active ?
361
-            if (! $form_step->initialize()) {
362
-                continue;
363
-            }
364
-            $progress_steps_collection->add(
365
-                new ProgressStep(
366
-                    $form_step->order(),
367
-                    $form_step->slug(),
368
-                    $form_step->slug(),
369
-                    $form_step->formName()
370
-                ),
371
-                $form_step->slug()
372
-            );
373
-        }
374
-        // set collection pointer back to current step
375
-        $this->form_steps->setCurrentUsingObject($current_step);
376
-        return new ProgressStepManager(
377
-            $this->progressStepStyle(),
378
-            $this->defaultFormStep(),
379
-            $this->formStepUrlKey(),
380
-            $progress_steps_collection
381
-        );
382
-    }
383
-
384
-
385
-    /**
386
-     * @throws InvalidClassException
387
-     * @throws InvalidDataTypeException
388
-     * @throws InvalidEntityException
389
-     * @throws InvalidIdentifierException
390
-     * @throws InvalidInterfaceException
391
-     * @throws InvalidArgumentException
392
-     * @throws InvalidFormHandlerException
393
-     */
394
-    public function buildForm()
395
-    {
396
-        $this->buildCurrentStepFormForDisplay();
397
-    }
398
-
399
-
400
-    /**
401
-     * @param array $form_data
402
-     * @throws InvalidArgumentException
403
-     * @throws InvalidClassException
404
-     * @throws InvalidDataTypeException
405
-     * @throws InvalidEntityException
406
-     * @throws InvalidFormHandlerException
407
-     * @throws InvalidIdentifierException
408
-     * @throws InvalidInterfaceException
409
-     */
410
-    public function processForm($form_data = array())
411
-    {
412
-        $this->buildCurrentStepFormForProcessing();
413
-        $this->processCurrentStepForm($form_data);
414
-    }
415
-
416
-
417
-    /**
418
-     * @throws InvalidClassException
419
-     * @throws InvalidDataTypeException
420
-     * @throws InvalidEntityException
421
-     * @throws InvalidInterfaceException
422
-     * @throws InvalidIdentifierException
423
-     * @throws InvalidArgumentException
424
-     * @throws InvalidFormHandlerException
425
-     */
426
-    public function buildCurrentStepFormForDisplay()
427
-    {
428
-        $form_step = $this->buildCurrentStepForm();
429
-        // no displayable content ? then skip straight to processing
430
-        if (! $form_step->displayable()) {
431
-            $this->addFormActionArgs();
432
-            $form_step->setFormAction($this->formAction());
433
-            wp_safe_redirect($form_step->formAction());
434
-        }
435
-    }
436
-
437
-
438
-    /**
439
-     * @throws InvalidClassException
440
-     * @throws InvalidDataTypeException
441
-     * @throws InvalidEntityException
442
-     * @throws InvalidInterfaceException
443
-     * @throws InvalidIdentifierException
444
-     * @throws InvalidArgumentException
445
-     * @throws InvalidFormHandlerException
446
-     */
447
-    public function buildCurrentStepFormForProcessing()
448
-    {
449
-        $this->buildCurrentStepForm(false);
450
-    }
451
-
452
-
453
-    /**
454
-     * @param bool $for_display
455
-     * @return SequentialStepFormInterface
456
-     * @throws InvalidArgumentException
457
-     * @throws InvalidClassException
458
-     * @throws InvalidDataTypeException
459
-     * @throws InvalidEntityException
460
-     * @throws InvalidFormHandlerException
461
-     * @throws InvalidIdentifierException
462
-     * @throws InvalidInterfaceException
463
-     */
464
-    private function buildCurrentStepForm($for_display = true)
465
-    {
466
-        $this->form_steps = $this->getFormStepsCollection();
467
-        $this->setCurrentStepFromRequest();
468
-        $form_step = $this->getCurrentStep();
469
-        if ($form_step->submitBtnText() === esc_html__('Submit', 'event_espresso')) {
470
-            $form_step->setSubmitBtnText(esc_html__('Next Step', 'event_espresso'));
471
-        }
472
-        if ($for_display && $form_step->displayable()) {
473
-            $this->progress_step_manager = $this->generateProgressSteps(
474
-                $this->getProgressStepsCollection()
475
-            );
476
-            $this->progress_step_manager->setCurrentStep(
477
-                $form_step->slug()
478
-            );
479
-            // mark all previous progress steps as completed
480
-            $this->progress_step_manager->setPreviousStepsCompleted();
481
-            $this->progress_step_manager->enqueueStylesAndScripts();
482
-            $this->addFormActionArgs();
483
-            $form_step->setFormAction($this->formAction());
484
-        } else {
485
-            $form_step->setRedirectUrl($this->baseUrl());
486
-            $form_step->addRedirectArgs(
487
-                array($this->formStepUrlKey() => $this->form_steps->current()->slug())
488
-            );
489
-        }
490
-        $form_step->generate();
491
-        if ($for_display) {
492
-            $form_step->enqueueStylesAndScripts();
493
-        }
494
-        return $form_step;
495
-    }
496
-
497
-
498
-    /**
499
-     * @param bool $return_as_string
500
-     * @return string
501
-     * @throws InvalidFormHandlerException
502
-     */
503
-    public function displayProgressSteps($return_as_string = true)
504
-    {
505
-        $form_step = $this->getCurrentStep();
506
-        if (! $form_step->displayable()) {
507
-            return '';
508
-        }
509
-        $progress_steps = apply_filters(
510
-            'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_SequentialStepFormManager__displayProgressSteps__before_steps',
511
-            ''
512
-        );
513
-        $progress_steps .= $this->progress_step_manager->displaySteps();
514
-        $progress_steps .= apply_filters(
515
-            'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_SequentialStepFormManager__displayProgressSteps__after_steps',
516
-            ''
517
-        );
518
-        if ($return_as_string) {
519
-            return $progress_steps;
520
-        }
521
-        echo $progress_steps;
522
-        return '';
523
-    }
524
-
525
-
526
-    /**
527
-     * @param bool $return_as_string
528
-     * @return string
529
-     * @throws InvalidFormHandlerException
530
-     */
531
-    public function displayCurrentStepForm($return_as_string = true)
532
-    {
533
-        if ($return_as_string) {
534
-            return $this->getCurrentStep()->display();
535
-        }
536
-        echo $this->getCurrentStep()->display();
537
-        return '';
538
-    }
539
-
540
-
541
-    /**
542
-     * @param array $form_data
543
-     * @return void
544
-     * @throws InvalidArgumentException
545
-     * @throws InvalidDataTypeException
546
-     * @throws InvalidFormHandlerException
547
-     */
548
-    public function processCurrentStepForm($form_data = array())
549
-    {
550
-        // grab instance of current step because after calling next() below,
551
-        // any calls to getCurrentStep() will return the "next" step because we advanced
552
-        $current_step = $this->getCurrentStep();
553
-        try {
554
-            // form processing should either throw exceptions or return true
555
-            $current_step->process($form_data);
556
-        } catch (Exception $e) {
557
-            // something went wrong, so...
558
-            // if WP_DEBUG === true, display the Exception and stack trace right now
559
-            new ExceptionStackTraceDisplay($e);
560
-            // else convert the Exception to an EE_Error
561
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
562
-            // prevent redirect to next step or other if exception was thrown
563
-            if ($current_step->redirectTo() === SequentialStepForm::REDIRECT_TO_NEXT_STEP
564
-                || $current_step->redirectTo() === SequentialStepForm::REDIRECT_TO_OTHER
565
-            ) {
566
-                $current_step->setRedirectTo(SequentialStepForm::REDIRECT_TO_CURRENT_STEP);
567
-            }
568
-        }
569
-        // save notices to a transient so that when we redirect back
570
-        // to the display portion for this step
571
-        // those notices can be displayed
572
-        EE_Error::get_notices(false, true);
573
-        $this->redirectForm($current_step);
574
-    }
575
-
576
-
577
-    /**
578
-     * handles where to go to next
579
-     *
580
-     * @param SequentialStepFormInterface $current_step
581
-     * @throws InvalidArgumentException
582
-     * @throws InvalidDataTypeException
583
-     * @throws InvalidFormHandlerException
584
-     */
585
-    public function redirectForm(SequentialStepFormInterface $current_step)
586
-    {
587
-        $redirect_step = $current_step;
588
-        switch ($current_step->redirectTo()) {
589
-            case SequentialStepForm::REDIRECT_TO_OTHER:
590
-                // going somewhere else, so just check out now
591
-                wp_safe_redirect($redirect_step->redirectUrl());
592
-                exit();
593
-                break;
594
-            case SequentialStepForm::REDIRECT_TO_PREV_STEP:
595
-                $redirect_step = $this->form_steps->previous();
596
-                break;
597
-            case SequentialStepForm::REDIRECT_TO_NEXT_STEP:
598
-                $this->form_steps->next();
599
-                if ($this->form_steps->valid()) {
600
-                    $redirect_step = $this->form_steps->current();
601
-                }
602
-                break;
603
-            case SequentialStepForm::REDIRECT_TO_CURRENT_STEP:
604
-            default:
605
-                // $redirect_step is already set
606
-        }
607
-        $current_step->setRedirectUrl($this->baseUrl());
608
-        $current_step->addRedirectArgs(
609
-            // use the slug for whatever step we are redirecting too
610
-            array($this->formStepUrlKey() => $redirect_step->slug())
611
-        );
612
-        wp_safe_redirect($current_step->redirectUrl());
613
-        exit();
614
-    }
32
+	/**
33
+	 * a simplified URL with no form related parameters
34
+	 * that will be used to build the form's redirect URLs
35
+	 *
36
+	 * @var string $base_url
37
+	 */
38
+	private $base_url = '';
39
+
40
+	/**
41
+	 * the key used for the URL param that denotes the current form step
42
+	 * defaults to 'ee-form-step'
43
+	 *
44
+	 * @var string $form_step_url_key
45
+	 */
46
+	private $form_step_url_key = '';
47
+
48
+	/**
49
+	 * @var string $default_form_step
50
+	 */
51
+	private $default_form_step = '';
52
+
53
+	/**
54
+	 * @var string $form_action
55
+	 */
56
+	private $form_action;
57
+
58
+	/**
59
+	 * value of one of the string constant above
60
+	 *
61
+	 * @var string $form_config
62
+	 */
63
+	private $form_config;
64
+
65
+	/**
66
+	 * @var string $progress_step_style
67
+	 */
68
+	private $progress_step_style = '';
69
+
70
+	/**
71
+	 * @var EE_Request $request
72
+	 */
73
+	private $request;
74
+
75
+	/**
76
+	 * @var Collection $form_steps
77
+	 */
78
+	protected $form_steps;
79
+
80
+	/**
81
+	 * @var ProgressStepManager $progress_step_manager
82
+	 */
83
+	protected $progress_step_manager;
84
+
85
+
86
+	/**
87
+	 * @return Collection|null
88
+	 */
89
+	abstract protected function getFormStepsCollection();
90
+
91
+	// phpcs:disable PEAR.Functions.ValidDefaultValue.NotAtEnd
92
+	/**
93
+	 * StepsManager constructor
94
+	 *
95
+	 * @param string     $base_url
96
+	 * @param string     $default_form_step
97
+	 * @param string     $form_action
98
+	 * @param string     $form_config
99
+	 * @param EE_Request $request
100
+	 * @param string     $progress_step_style
101
+	 * @throws InvalidDataTypeException
102
+	 * @throws InvalidArgumentException
103
+	 */
104
+	public function __construct(
105
+		$base_url,
106
+		$default_form_step,
107
+		$form_action = '',
108
+		$form_config = FormHandler::ADD_FORM_TAGS_AND_SUBMIT,
109
+		$progress_step_style = 'number_bubbles',
110
+		EE_Request $request
111
+	) {
112
+		$this->setBaseUrl($base_url);
113
+		$this->setDefaultFormStep($default_form_step);
114
+		$this->setFormAction($form_action);
115
+		$this->setFormConfig($form_config);
116
+		$this->setProgressStepStyle($progress_step_style);
117
+		$this->request = $request;
118
+	}
119
+
120
+
121
+	/**
122
+	 * @return string
123
+	 * @throws InvalidFormHandlerException
124
+	 */
125
+	public function baseUrl()
126
+	{
127
+		if (strpos($this->base_url, $this->getCurrentStep()->slug()) === false) {
128
+			add_query_arg(
129
+				array($this->form_step_url_key => $this->getCurrentStep()->slug()),
130
+				$this->base_url
131
+			);
132
+		}
133
+		return $this->base_url;
134
+	}
135
+
136
+
137
+	/**
138
+	 * @param string $base_url
139
+	 * @throws InvalidDataTypeException
140
+	 * @throws InvalidArgumentException
141
+	 */
142
+	protected function setBaseUrl($base_url)
143
+	{
144
+		if (! is_string($base_url)) {
145
+			throw new InvalidDataTypeException('$base_url', $base_url, 'string');
146
+		}
147
+		if (empty($base_url)) {
148
+			throw new InvalidArgumentException(
149
+				esc_html__('The base URL can not be an empty string.', 'event_espresso')
150
+			);
151
+		}
152
+		$this->base_url = $base_url;
153
+	}
154
+
155
+
156
+	/**
157
+	 * @return string
158
+	 * @throws InvalidDataTypeException
159
+	 */
160
+	public function formStepUrlKey()
161
+	{
162
+		if (empty($this->form_step_url_key)) {
163
+			$this->setFormStepUrlKey();
164
+		}
165
+		return $this->form_step_url_key;
166
+	}
167
+
168
+
169
+	/**
170
+	 * @param string $form_step_url_key
171
+	 * @throws InvalidDataTypeException
172
+	 */
173
+	public function setFormStepUrlKey($form_step_url_key = 'ee-form-step')
174
+	{
175
+		if (! is_string($form_step_url_key)) {
176
+			throw new InvalidDataTypeException('$form_step_key', $form_step_url_key, 'string');
177
+		}
178
+		$this->form_step_url_key = ! empty($form_step_url_key) ? $form_step_url_key : 'ee-form-step';
179
+	}
180
+
181
+
182
+	/**
183
+	 * @return string
184
+	 */
185
+	public function defaultFormStep()
186
+	{
187
+		return $this->default_form_step;
188
+	}
189
+
190
+
191
+	/**
192
+	 * @param $default_form_step
193
+	 * @throws InvalidDataTypeException
194
+	 */
195
+	protected function setDefaultFormStep($default_form_step)
196
+	{
197
+		if (! is_string($default_form_step)) {
198
+			throw new InvalidDataTypeException('$default_form_step', $default_form_step, 'string');
199
+		}
200
+		$this->default_form_step = $default_form_step;
201
+	}
202
+
203
+
204
+	/**
205
+	 * @return void
206
+	 * @throws \EventEspresso\core\exceptions\InvalidIdentifierException
207
+	 * @throws InvalidDataTypeException
208
+	 */
209
+	protected function setCurrentStepFromRequest()
210
+	{
211
+		$current_step_slug = $this->request()->get($this->formStepUrlKey(), $this->defaultFormStep());
212
+		if (! $this->form_steps->setCurrent($current_step_slug)) {
213
+			throw new InvalidIdentifierException(
214
+				$current_step_slug,
215
+				$this->defaultFormStep(),
216
+				$message = sprintf(
217
+					esc_html__(
218
+						'The "%1$s" form step could not be set.',
219
+						'event_espresso'
220
+					),
221
+					$current_step_slug
222
+				)
223
+			);
224
+		}
225
+	}
226
+
227
+
228
+	/**
229
+	 * @return object|SequentialStepFormInterface
230
+	 * @throws InvalidFormHandlerException
231
+	 */
232
+	public function getCurrentStep()
233
+	{
234
+		if (! $this->form_steps->current() instanceof SequentialStepForm) {
235
+			throw new InvalidFormHandlerException($this->form_steps->current());
236
+		}
237
+		return $this->form_steps->current();
238
+	}
239
+
240
+
241
+	/**
242
+	 * @return string
243
+	 * @throws InvalidFormHandlerException
244
+	 */
245
+	public function formAction()
246
+	{
247
+		if (! is_string($this->form_action) || empty($this->form_action)) {
248
+			$this->form_action = $this->baseUrl();
249
+		}
250
+		return $this->form_action;
251
+	}
252
+
253
+
254
+	/**
255
+	 * @param string $form_action
256
+	 * @throws InvalidDataTypeException
257
+	 */
258
+	public function setFormAction($form_action)
259
+	{
260
+		if (! is_string($form_action)) {
261
+			throw new InvalidDataTypeException('$form_action', $form_action, 'string');
262
+		}
263
+		$this->form_action = $form_action;
264
+	}
265
+
266
+
267
+	/**
268
+	 * @param array $form_action_args
269
+	 * @throws InvalidDataTypeException
270
+	 * @throws InvalidFormHandlerException
271
+	 */
272
+	public function addFormActionArgs($form_action_args = array())
273
+	{
274
+		if (! is_array($form_action_args)) {
275
+			throw new InvalidDataTypeException('$form_action_args', $form_action_args, 'array');
276
+		}
277
+		$form_action_args = ! empty($form_action_args)
278
+			? $form_action_args
279
+			: array($this->formStepUrlKey() => $this->form_steps->current()->slug());
280
+		$this->getCurrentStep()->setFormAction(
281
+			add_query_arg($form_action_args, $this->formAction())
282
+		);
283
+		$this->form_action = $this->getCurrentStep()->formAction();
284
+	}
285
+
286
+
287
+	/**
288
+	 * @return string
289
+	 */
290
+	public function formConfig()
291
+	{
292
+		return $this->form_config;
293
+	}
294
+
295
+
296
+	/**
297
+	 * @param string $form_config
298
+	 */
299
+	public function setFormConfig($form_config)
300
+	{
301
+		$this->form_config = $form_config;
302
+	}
303
+
304
+
305
+	/**
306
+	 * @return string
307
+	 */
308
+	public function progressStepStyle()
309
+	{
310
+		return $this->progress_step_style;
311
+	}
312
+
313
+
314
+	/**
315
+	 * @param string $progress_step_style
316
+	 */
317
+	public function setProgressStepStyle($progress_step_style)
318
+	{
319
+		$this->progress_step_style = $progress_step_style;
320
+	}
321
+
322
+
323
+	/**
324
+	 * @return EE_Request
325
+	 */
326
+	public function request()
327
+	{
328
+		return $this->request;
329
+	}
330
+
331
+
332
+	/**
333
+	 * @return Collection|null
334
+	 * @throws InvalidInterfaceException
335
+	 */
336
+	protected function getProgressStepsCollection()
337
+	{
338
+		static $collection = null;
339
+		if (! $collection instanceof ProgressStepCollection) {
340
+			$collection = new ProgressStepCollection();
341
+		}
342
+		return $collection;
343
+	}
344
+
345
+
346
+	/**
347
+	 * @param Collection $progress_steps_collection
348
+	 * @return ProgressStepManager
349
+	 * @throws InvalidInterfaceException
350
+	 * @throws InvalidClassException
351
+	 * @throws InvalidDataTypeException
352
+	 * @throws InvalidEntityException
353
+	 * @throws InvalidFormHandlerException
354
+	 */
355
+	protected function generateProgressSteps(Collection $progress_steps_collection)
356
+	{
357
+		$current_step = $this->getCurrentStep();
358
+		/** @var SequentialStepForm $form_step */
359
+		foreach ($this->form_steps as $form_step) {
360
+			// is this step active ?
361
+			if (! $form_step->initialize()) {
362
+				continue;
363
+			}
364
+			$progress_steps_collection->add(
365
+				new ProgressStep(
366
+					$form_step->order(),
367
+					$form_step->slug(),
368
+					$form_step->slug(),
369
+					$form_step->formName()
370
+				),
371
+				$form_step->slug()
372
+			);
373
+		}
374
+		// set collection pointer back to current step
375
+		$this->form_steps->setCurrentUsingObject($current_step);
376
+		return new ProgressStepManager(
377
+			$this->progressStepStyle(),
378
+			$this->defaultFormStep(),
379
+			$this->formStepUrlKey(),
380
+			$progress_steps_collection
381
+		);
382
+	}
383
+
384
+
385
+	/**
386
+	 * @throws InvalidClassException
387
+	 * @throws InvalidDataTypeException
388
+	 * @throws InvalidEntityException
389
+	 * @throws InvalidIdentifierException
390
+	 * @throws InvalidInterfaceException
391
+	 * @throws InvalidArgumentException
392
+	 * @throws InvalidFormHandlerException
393
+	 */
394
+	public function buildForm()
395
+	{
396
+		$this->buildCurrentStepFormForDisplay();
397
+	}
398
+
399
+
400
+	/**
401
+	 * @param array $form_data
402
+	 * @throws InvalidArgumentException
403
+	 * @throws InvalidClassException
404
+	 * @throws InvalidDataTypeException
405
+	 * @throws InvalidEntityException
406
+	 * @throws InvalidFormHandlerException
407
+	 * @throws InvalidIdentifierException
408
+	 * @throws InvalidInterfaceException
409
+	 */
410
+	public function processForm($form_data = array())
411
+	{
412
+		$this->buildCurrentStepFormForProcessing();
413
+		$this->processCurrentStepForm($form_data);
414
+	}
415
+
416
+
417
+	/**
418
+	 * @throws InvalidClassException
419
+	 * @throws InvalidDataTypeException
420
+	 * @throws InvalidEntityException
421
+	 * @throws InvalidInterfaceException
422
+	 * @throws InvalidIdentifierException
423
+	 * @throws InvalidArgumentException
424
+	 * @throws InvalidFormHandlerException
425
+	 */
426
+	public function buildCurrentStepFormForDisplay()
427
+	{
428
+		$form_step = $this->buildCurrentStepForm();
429
+		// no displayable content ? then skip straight to processing
430
+		if (! $form_step->displayable()) {
431
+			$this->addFormActionArgs();
432
+			$form_step->setFormAction($this->formAction());
433
+			wp_safe_redirect($form_step->formAction());
434
+		}
435
+	}
436
+
437
+
438
+	/**
439
+	 * @throws InvalidClassException
440
+	 * @throws InvalidDataTypeException
441
+	 * @throws InvalidEntityException
442
+	 * @throws InvalidInterfaceException
443
+	 * @throws InvalidIdentifierException
444
+	 * @throws InvalidArgumentException
445
+	 * @throws InvalidFormHandlerException
446
+	 */
447
+	public function buildCurrentStepFormForProcessing()
448
+	{
449
+		$this->buildCurrentStepForm(false);
450
+	}
451
+
452
+
453
+	/**
454
+	 * @param bool $for_display
455
+	 * @return SequentialStepFormInterface
456
+	 * @throws InvalidArgumentException
457
+	 * @throws InvalidClassException
458
+	 * @throws InvalidDataTypeException
459
+	 * @throws InvalidEntityException
460
+	 * @throws InvalidFormHandlerException
461
+	 * @throws InvalidIdentifierException
462
+	 * @throws InvalidInterfaceException
463
+	 */
464
+	private function buildCurrentStepForm($for_display = true)
465
+	{
466
+		$this->form_steps = $this->getFormStepsCollection();
467
+		$this->setCurrentStepFromRequest();
468
+		$form_step = $this->getCurrentStep();
469
+		if ($form_step->submitBtnText() === esc_html__('Submit', 'event_espresso')) {
470
+			$form_step->setSubmitBtnText(esc_html__('Next Step', 'event_espresso'));
471
+		}
472
+		if ($for_display && $form_step->displayable()) {
473
+			$this->progress_step_manager = $this->generateProgressSteps(
474
+				$this->getProgressStepsCollection()
475
+			);
476
+			$this->progress_step_manager->setCurrentStep(
477
+				$form_step->slug()
478
+			);
479
+			// mark all previous progress steps as completed
480
+			$this->progress_step_manager->setPreviousStepsCompleted();
481
+			$this->progress_step_manager->enqueueStylesAndScripts();
482
+			$this->addFormActionArgs();
483
+			$form_step->setFormAction($this->formAction());
484
+		} else {
485
+			$form_step->setRedirectUrl($this->baseUrl());
486
+			$form_step->addRedirectArgs(
487
+				array($this->formStepUrlKey() => $this->form_steps->current()->slug())
488
+			);
489
+		}
490
+		$form_step->generate();
491
+		if ($for_display) {
492
+			$form_step->enqueueStylesAndScripts();
493
+		}
494
+		return $form_step;
495
+	}
496
+
497
+
498
+	/**
499
+	 * @param bool $return_as_string
500
+	 * @return string
501
+	 * @throws InvalidFormHandlerException
502
+	 */
503
+	public function displayProgressSteps($return_as_string = true)
504
+	{
505
+		$form_step = $this->getCurrentStep();
506
+		if (! $form_step->displayable()) {
507
+			return '';
508
+		}
509
+		$progress_steps = apply_filters(
510
+			'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_SequentialStepFormManager__displayProgressSteps__before_steps',
511
+			''
512
+		);
513
+		$progress_steps .= $this->progress_step_manager->displaySteps();
514
+		$progress_steps .= apply_filters(
515
+			'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_SequentialStepFormManager__displayProgressSteps__after_steps',
516
+			''
517
+		);
518
+		if ($return_as_string) {
519
+			return $progress_steps;
520
+		}
521
+		echo $progress_steps;
522
+		return '';
523
+	}
524
+
525
+
526
+	/**
527
+	 * @param bool $return_as_string
528
+	 * @return string
529
+	 * @throws InvalidFormHandlerException
530
+	 */
531
+	public function displayCurrentStepForm($return_as_string = true)
532
+	{
533
+		if ($return_as_string) {
534
+			return $this->getCurrentStep()->display();
535
+		}
536
+		echo $this->getCurrentStep()->display();
537
+		return '';
538
+	}
539
+
540
+
541
+	/**
542
+	 * @param array $form_data
543
+	 * @return void
544
+	 * @throws InvalidArgumentException
545
+	 * @throws InvalidDataTypeException
546
+	 * @throws InvalidFormHandlerException
547
+	 */
548
+	public function processCurrentStepForm($form_data = array())
549
+	{
550
+		// grab instance of current step because after calling next() below,
551
+		// any calls to getCurrentStep() will return the "next" step because we advanced
552
+		$current_step = $this->getCurrentStep();
553
+		try {
554
+			// form processing should either throw exceptions or return true
555
+			$current_step->process($form_data);
556
+		} catch (Exception $e) {
557
+			// something went wrong, so...
558
+			// if WP_DEBUG === true, display the Exception and stack trace right now
559
+			new ExceptionStackTraceDisplay($e);
560
+			// else convert the Exception to an EE_Error
561
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
562
+			// prevent redirect to next step or other if exception was thrown
563
+			if ($current_step->redirectTo() === SequentialStepForm::REDIRECT_TO_NEXT_STEP
564
+				|| $current_step->redirectTo() === SequentialStepForm::REDIRECT_TO_OTHER
565
+			) {
566
+				$current_step->setRedirectTo(SequentialStepForm::REDIRECT_TO_CURRENT_STEP);
567
+			}
568
+		}
569
+		// save notices to a transient so that when we redirect back
570
+		// to the display portion for this step
571
+		// those notices can be displayed
572
+		EE_Error::get_notices(false, true);
573
+		$this->redirectForm($current_step);
574
+	}
575
+
576
+
577
+	/**
578
+	 * handles where to go to next
579
+	 *
580
+	 * @param SequentialStepFormInterface $current_step
581
+	 * @throws InvalidArgumentException
582
+	 * @throws InvalidDataTypeException
583
+	 * @throws InvalidFormHandlerException
584
+	 */
585
+	public function redirectForm(SequentialStepFormInterface $current_step)
586
+	{
587
+		$redirect_step = $current_step;
588
+		switch ($current_step->redirectTo()) {
589
+			case SequentialStepForm::REDIRECT_TO_OTHER:
590
+				// going somewhere else, so just check out now
591
+				wp_safe_redirect($redirect_step->redirectUrl());
592
+				exit();
593
+				break;
594
+			case SequentialStepForm::REDIRECT_TO_PREV_STEP:
595
+				$redirect_step = $this->form_steps->previous();
596
+				break;
597
+			case SequentialStepForm::REDIRECT_TO_NEXT_STEP:
598
+				$this->form_steps->next();
599
+				if ($this->form_steps->valid()) {
600
+					$redirect_step = $this->form_steps->current();
601
+				}
602
+				break;
603
+			case SequentialStepForm::REDIRECT_TO_CURRENT_STEP:
604
+			default:
605
+				// $redirect_step is already set
606
+		}
607
+		$current_step->setRedirectUrl($this->baseUrl());
608
+		$current_step->addRedirectArgs(
609
+			// use the slug for whatever step we are redirecting too
610
+			array($this->formStepUrlKey() => $redirect_step->slug())
611
+		);
612
+		wp_safe_redirect($current_step->redirectUrl());
613
+		exit();
614
+	}
615 615
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
      */
142 142
     protected function setBaseUrl($base_url)
143 143
     {
144
-        if (! is_string($base_url)) {
144
+        if ( ! is_string($base_url)) {
145 145
             throw new InvalidDataTypeException('$base_url', $base_url, 'string');
146 146
         }
147 147
         if (empty($base_url)) {
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
      */
173 173
     public function setFormStepUrlKey($form_step_url_key = 'ee-form-step')
174 174
     {
175
-        if (! is_string($form_step_url_key)) {
175
+        if ( ! is_string($form_step_url_key)) {
176 176
             throw new InvalidDataTypeException('$form_step_key', $form_step_url_key, 'string');
177 177
         }
178 178
         $this->form_step_url_key = ! empty($form_step_url_key) ? $form_step_url_key : 'ee-form-step';
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
      */
195 195
     protected function setDefaultFormStep($default_form_step)
196 196
     {
197
-        if (! is_string($default_form_step)) {
197
+        if ( ! is_string($default_form_step)) {
198 198
             throw new InvalidDataTypeException('$default_form_step', $default_form_step, 'string');
199 199
         }
200 200
         $this->default_form_step = $default_form_step;
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
     protected function setCurrentStepFromRequest()
210 210
     {
211 211
         $current_step_slug = $this->request()->get($this->formStepUrlKey(), $this->defaultFormStep());
212
-        if (! $this->form_steps->setCurrent($current_step_slug)) {
212
+        if ( ! $this->form_steps->setCurrent($current_step_slug)) {
213 213
             throw new InvalidIdentifierException(
214 214
                 $current_step_slug,
215 215
                 $this->defaultFormStep(),
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
      */
232 232
     public function getCurrentStep()
233 233
     {
234
-        if (! $this->form_steps->current() instanceof SequentialStepForm) {
234
+        if ( ! $this->form_steps->current() instanceof SequentialStepForm) {
235 235
             throw new InvalidFormHandlerException($this->form_steps->current());
236 236
         }
237 237
         return $this->form_steps->current();
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
      */
245 245
     public function formAction()
246 246
     {
247
-        if (! is_string($this->form_action) || empty($this->form_action)) {
247
+        if ( ! is_string($this->form_action) || empty($this->form_action)) {
248 248
             $this->form_action = $this->baseUrl();
249 249
         }
250 250
         return $this->form_action;
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
      */
258 258
     public function setFormAction($form_action)
259 259
     {
260
-        if (! is_string($form_action)) {
260
+        if ( ! is_string($form_action)) {
261 261
             throw new InvalidDataTypeException('$form_action', $form_action, 'string');
262 262
         }
263 263
         $this->form_action = $form_action;
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
      */
272 272
     public function addFormActionArgs($form_action_args = array())
273 273
     {
274
-        if (! is_array($form_action_args)) {
274
+        if ( ! is_array($form_action_args)) {
275 275
             throw new InvalidDataTypeException('$form_action_args', $form_action_args, 'array');
276 276
         }
277 277
         $form_action_args = ! empty($form_action_args)
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
     protected function getProgressStepsCollection()
337 337
     {
338 338
         static $collection = null;
339
-        if (! $collection instanceof ProgressStepCollection) {
339
+        if ( ! $collection instanceof ProgressStepCollection) {
340 340
             $collection = new ProgressStepCollection();
341 341
         }
342 342
         return $collection;
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
         /** @var SequentialStepForm $form_step */
359 359
         foreach ($this->form_steps as $form_step) {
360 360
             // is this step active ?
361
-            if (! $form_step->initialize()) {
361
+            if ( ! $form_step->initialize()) {
362 362
                 continue;
363 363
             }
364 364
             $progress_steps_collection->add(
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
     {
428 428
         $form_step = $this->buildCurrentStepForm();
429 429
         // no displayable content ? then skip straight to processing
430
-        if (! $form_step->displayable()) {
430
+        if ( ! $form_step->displayable()) {
431 431
             $this->addFormActionArgs();
432 432
             $form_step->setFormAction($this->formAction());
433 433
             wp_safe_redirect($form_step->formAction());
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
     public function displayProgressSteps($return_as_string = true)
504 504
     {
505 505
         $form_step = $this->getCurrentStep();
506
-        if (! $form_step->displayable()) {
506
+        if ( ! $form_step->displayable()) {
507 507
             return '';
508 508
         }
509 509
         $progress_steps = apply_filters(
Please login to merge, or discard this patch.
core/libraries/form_sections/form_handlers/InvalidFormHandlerException.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -13,25 +13,25 @@
 block discarded – undo
13 13
 class InvalidFormHandlerException extends \UnexpectedValueException
14 14
 {
15 15
 
16
-    /**
17
-     * InvalidFormHandlerException constructor.
18
-     *
19
-     * @param string     $actual the FormHandler object that was received
20
-     * @param string     $message
21
-     * @param int        $code
22
-     * @param \Exception $previous
23
-     */
24
-    public function __construct($actual, $message = '', $code = 0, \Exception $previous = null)
25
-    {
26
-        if (empty($message)) {
27
-            $message = sprintf(
28
-                __(
29
-                    'A valid Form Handler was expected but instead "%1$s" was received.',
30
-                    'event_espresso'
31
-                ),
32
-                $actual
33
-            );
34
-        }
35
-        parent::__construct($message, $code, $previous);
36
-    }
16
+	/**
17
+	 * InvalidFormHandlerException constructor.
18
+	 *
19
+	 * @param string     $actual the FormHandler object that was received
20
+	 * @param string     $message
21
+	 * @param int        $code
22
+	 * @param \Exception $previous
23
+	 */
24
+	public function __construct($actual, $message = '', $code = 0, \Exception $previous = null)
25
+	{
26
+		if (empty($message)) {
27
+			$message = sprintf(
28
+				__(
29
+					'A valid Form Handler was expected but instead "%1$s" was received.',
30
+					'event_espresso'
31
+				),
32
+				$actual
33
+			);
34
+		}
35
+		parent::__construct($message, $code, $previous);
36
+	}
37 37
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/strategies/filter/FormHtmlFilter.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -14,10 +14,10 @@
 block discarded – undo
14 14
 abstract class FormHtmlFilter
15 15
 {
16 16
 
17
-    /**
18
-     * @param                             $html
19
-     * @param EE_Form_Section_Validatable $form_section
20
-     * @return string
21
-     */
22
-    abstract public function filterHtml($html, EE_Form_Section_Validatable $form_section);
17
+	/**
18
+	 * @param                             $html
19
+	 * @param EE_Form_Section_Validatable $form_section
20
+	 * @return string
21
+	 */
22
+	abstract public function filterHtml($html, EE_Form_Section_Validatable $form_section);
23 23
 }
Please login to merge, or discard this patch.
core/libraries/iframe_display/EventListIframeEmbedButton.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -12,49 +12,49 @@
 block discarded – undo
12 12
 class EventListIframeEmbedButton extends IframeEmbedButton
13 13
 {
14 14
 
15
-    /**
16
-     * EventListIframeEmbedButton constructor.
17
-     */
18
-    public function __construct()
19
-    {
20
-        parent::__construct(
21
-            esc_html__('Upcoming Event List', 'event_espresso'),
22
-            'event_list'
23
-        );
24
-    }
15
+	/**
16
+	 * EventListIframeEmbedButton constructor.
17
+	 */
18
+	public function __construct()
19
+	{
20
+		parent::__construct(
21
+			esc_html__('Upcoming Event List', 'event_espresso'),
22
+			'event_list'
23
+		);
24
+	}
25 25
 
26 26
 
27
-    public function addEmbedButton()
28
-    {
29
-        add_filter(
30
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
31
-            array($this, 'addEventListIframeEmbedButtonSection')
32
-        );
33
-        add_action(
34
-            'admin_enqueue_scripts',
35
-            array($this, 'embedButtonAssets'),
36
-            10
37
-        );
38
-    }
27
+	public function addEmbedButton()
28
+	{
29
+		add_filter(
30
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
31
+			array($this, 'addEventListIframeEmbedButtonSection')
32
+		);
33
+		add_action(
34
+			'admin_enqueue_scripts',
35
+			array($this, 'embedButtonAssets'),
36
+			10
37
+		);
38
+	}
39 39
 
40 40
 
41
-    /**
42
-     * Adds an iframe embed code button to the Event editor.
43
-     * return string
44
-     *
45
-     * @param array $after_list_table
46
-     * @return array
47
-     */
48
-    public function addEventListIframeEmbedButtonSection(array $after_list_table)
49
-    {
50
-        return \EEH_Array::insert_into_array(
51
-            $after_list_table,
52
-            array(
53
-                'iframe_embed_buttons' => $this->addIframeEmbedButtonsSection(
54
-                    array('event_list' => $this->embedButtonHtml())
55
-                ),
56
-            ),
57
-            'legend'
58
-        );
59
-    }
41
+	/**
42
+	 * Adds an iframe embed code button to the Event editor.
43
+	 * return string
44
+	 *
45
+	 * @param array $after_list_table
46
+	 * @return array
47
+	 */
48
+	public function addEventListIframeEmbedButtonSection(array $after_list_table)
49
+	{
50
+		return \EEH_Array::insert_into_array(
51
+			$after_list_table,
52
+			array(
53
+				'iframe_embed_buttons' => $this->addIframeEmbedButtonsSection(
54
+					array('event_list' => $this->embedButtonHtml())
55
+				),
56
+			),
57
+			'legend'
58
+		);
59
+	}
60 60
 }
Please login to merge, or discard this patch.
core/libraries/rest_api/RestException.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -14,54 +14,54 @@
 block discarded – undo
14 14
 class RestException extends \EE_Error
15 15
 {
16 16
 
17
-    /**
18
-     * @var array
19
-     */
20
-    protected $wp_error_data = array();
17
+	/**
18
+	 * @var array
19
+	 */
20
+	protected $wp_error_data = array();
21 21
 
22
-    protected $wp_error_code = '';
22
+	protected $wp_error_code = '';
23 23
 
24 24
 
25 25
 
26
-    public function __construct($string_code, $message, $wp_error_data = array(), $previous = null)
27
-    {
28
-        if (is_array($wp_error_data)
29
-            && isset($wp_error_data['status'])
30
-        ) {
31
-            $http_status_number = $wp_error_data['status'];
32
-        } else {
33
-            $http_status_number = 500;
34
-        }
35
-        parent::__construct(
36
-            $message,
37
-            $http_status_number,
38
-            $previous
39
-        );
40
-        $this->wp_error_data = $wp_error_data;
41
-        $this->wp_error_code = $string_code;
42
-    }
26
+	public function __construct($string_code, $message, $wp_error_data = array(), $previous = null)
27
+	{
28
+		if (is_array($wp_error_data)
29
+			&& isset($wp_error_data['status'])
30
+		) {
31
+			$http_status_number = $wp_error_data['status'];
32
+		} else {
33
+			$http_status_number = 500;
34
+		}
35
+		parent::__construct(
36
+			$message,
37
+			$http_status_number,
38
+			$previous
39
+		);
40
+		$this->wp_error_data = $wp_error_data;
41
+		$this->wp_error_code = $string_code;
42
+	}
43 43
 
44 44
 
45 45
 
46
-    /**
47
-     * Array of data that may have been set during the constructor, intended for WP_Error's data
48
-     *
49
-     * @return array
50
-     */
51
-    public function getData()
52
-    {
53
-        return $this->wp_error_data;
54
-    }
46
+	/**
47
+	 * Array of data that may have been set during the constructor, intended for WP_Error's data
48
+	 *
49
+	 * @return array
50
+	 */
51
+	public function getData()
52
+	{
53
+		return $this->wp_error_data;
54
+	}
55 55
 
56 56
 
57 57
 
58
-    /**
59
-     * Gets the error string
60
-     *
61
-     * @return string
62
-     */
63
-    public function getStringCode()
64
-    {
65
-        return $this->wp_error_code;
66
-    }
58
+	/**
59
+	 * Gets the error string
60
+	 *
61
+	 * @return string
62
+	 */
63
+	public function getStringCode()
64
+	{
65
+		return $this->wp_error_code;
66
+	}
67 67
 }
Please login to merge, or discard this patch.
core/libraries/rest_api/changes/ChangesIn40834.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -10,38 +10,38 @@
 block discarded – undo
10 10
 class ChangesIn40834 extends ChangesInBase
11 11
 {
12 12
 
13
-    /**
14
-     * Adds hooks so requests to 4.8.29 don't have the checkin endpoints
15
-     */
16
-    public function setHooks()
17
-    {
18
-        // set a hook to remove the checkout/checkout endpoints if the request
19
-        // is for lower than 4.8.33
20
-        add_filter(
21
-            'FHEE__EventEspresso\core\libraries\rest_api\controllers\Base___get_response_headers',
22
-            array($this, 'removeResponseHeaders'),
23
-            10,
24
-            3
25
-        );
26
-    }
13
+	/**
14
+	 * Adds hooks so requests to 4.8.29 don't have the checkin endpoints
15
+	 */
16
+	public function setHooks()
17
+	{
18
+		// set a hook to remove the checkout/checkout endpoints if the request
19
+		// is for lower than 4.8.33
20
+		add_filter(
21
+			'FHEE__EventEspresso\core\libraries\rest_api\controllers\Base___get_response_headers',
22
+			array($this, 'removeResponseHeaders'),
23
+			10,
24
+			3
25
+		);
26
+	}
27 27
 
28 28
 
29
-    /**
30
-     * Removes the checkin and checkout endpoints from the index for requests
31
-     * to api versions lowers than 4.8.33
32
-     *
33
-     * @param array  $response_headers
34
-     * @param Base   $controller
35
-     * @param string $requested_version
36
-     * @return array like $routes_on_this_version
37
-     */
38
-    public function removeResponseHeaders($response_headers, $controller, $requested_version)
39
-    {
40
-        if ($controller instanceof Base
41
-            && $this->appliesToVersion($requested_version)
42
-        ) {
43
-            return array();
44
-        }
45
-        return $response_headers;
46
-    }
29
+	/**
30
+	 * Removes the checkin and checkout endpoints from the index for requests
31
+	 * to api versions lowers than 4.8.33
32
+	 *
33
+	 * @param array  $response_headers
34
+	 * @param Base   $controller
35
+	 * @param string $requested_version
36
+	 * @return array like $routes_on_this_version
37
+	 */
38
+	public function removeResponseHeaders($response_headers, $controller, $requested_version)
39
+	{
40
+		if ($controller instanceof Base
41
+			&& $this->appliesToVersion($requested_version)
42
+		) {
43
+			return array();
44
+		}
45
+		return $response_headers;
46
+	}
47 47
 }
Please login to merge, or discard this patch.
core/libraries/rest_api/changes/ChangesIn40833.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -7,57 +7,57 @@
 block discarded – undo
7 7
 class ChangesIn40833 extends ChangesInBase
8 8
 {
9 9
 
10
-    /**
11
-     * Adds hooks so requests to 4.8.29 don't have the checkin endpoints
12
-     */
13
-    public function setHooks()
14
-    {
15
-        // set a hook to remove the checkout/checkout endpoints if the request
16
-        // is for lower than 4.8.33
17
-        add_filter(
18
-            'FHEE__EED_Core_Rest_Api___register_rpc_routes__this_versions_routes',
19
-            array($this, 'removeCheckinRoutesEarlierThan4833'),
20
-            10,
21
-            2
22
-        );
23
-        add_filter(
24
-            'FHEE__EventEspresso\core\libraries\rest_api\controllers\Base___get_headers_from_ee_notices__return',
25
-            array($this, 'dontAddHeadersFromEeNotices'),
26
-            10,
27
-            2
28
-        );
29
-    }
10
+	/**
11
+	 * Adds hooks so requests to 4.8.29 don't have the checkin endpoints
12
+	 */
13
+	public function setHooks()
14
+	{
15
+		// set a hook to remove the checkout/checkout endpoints if the request
16
+		// is for lower than 4.8.33
17
+		add_filter(
18
+			'FHEE__EED_Core_Rest_Api___register_rpc_routes__this_versions_routes',
19
+			array($this, 'removeCheckinRoutesEarlierThan4833'),
20
+			10,
21
+			2
22
+		);
23
+		add_filter(
24
+			'FHEE__EventEspresso\core\libraries\rest_api\controllers\Base___get_headers_from_ee_notices__return',
25
+			array($this, 'dontAddHeadersFromEeNotices'),
26
+			10,
27
+			2
28
+		);
29
+	}
30 30
 
31 31
 
32
-    /**
33
-     * Removes the checkin and checkout endpoints from the index for requests
34
-     * to api versions lowers than 4.8.33
35
-     *
36
-     * @param array  $routes_on_this_version
37
-     * @param string $version
38
-     * @return array like $routes_on_this_version
39
-     */
40
-    public function removeCheckinRoutesEarlierThan4833($routes_on_this_version, $version)
41
-    {
42
-        if ($this->appliesToVersion($version)) {
43
-            unset($routes_on_this_version['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)']);
44
-        }
45
-        return $routes_on_this_version;
46
-    }
32
+	/**
33
+	 * Removes the checkin and checkout endpoints from the index for requests
34
+	 * to api versions lowers than 4.8.33
35
+	 *
36
+	 * @param array  $routes_on_this_version
37
+	 * @param string $version
38
+	 * @return array like $routes_on_this_version
39
+	 */
40
+	public function removeCheckinRoutesEarlierThan4833($routes_on_this_version, $version)
41
+	{
42
+		if ($this->appliesToVersion($version)) {
43
+			unset($routes_on_this_version['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)']);
44
+		}
45
+		return $routes_on_this_version;
46
+	}
47 47
 
48 48
 
49
-    /**
50
-     * We just added headers for notices in this version
51
-     *
52
-     * @param array  $headers_from_ee_notices
53
-     * @param string $requested_version
54
-     * @return array
55
-     */
56
-    public function dontAddHeadersFromEeNotices($headers_from_ee_notices, $requested_version)
57
-    {
58
-        if ($this->appliesToVersion($requested_version)) {
59
-            return array();
60
-        }
61
-        return $headers_from_ee_notices;
62
-    }
49
+	/**
50
+	 * We just added headers for notices in this version
51
+	 *
52
+	 * @param array  $headers_from_ee_notices
53
+	 * @param string $requested_version
54
+	 * @return array
55
+	 */
56
+	public function dontAddHeadersFromEeNotices($headers_from_ee_notices, $requested_version)
57
+	{
58
+		if ($this->appliesToVersion($requested_version)) {
59
+			return array();
60
+		}
61
+		return $headers_from_ee_notices;
62
+	}
63 63
 }
Please login to merge, or discard this patch.
core/libraries/rest_api/calculations/Base.php 2 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -16,40 +16,40 @@
 block discarded – undo
16 16
 class Base
17 17
 {
18 18
 
19
-    /**
20
-     * @param $required_permission
21
-     * @param $attempted_calculation
22
-     * @throws \EventEspresso\core\libraries\rest_api\RestException
23
-     */
24
-    protected static function verifyCurrentUserCan($required_permission, $attempted_calculation)
25
-    {
26
-        if (! current_user_can($required_permission)) {
27
-            throw new RestException(
28
-                'permission_denied',
29
-                sprintf(
30
-                    __(
31
-                    // @codingStandardsIgnoreStart
32
-                        'Permission denied, you cannot calculate %1$s on %2$s because you do not have the capability "%3$s"',
33
-                        // @codingStandardsIgnoreEnd
34
-                        'event_espresso'
35
-                    ),
36
-                    $attempted_calculation,
37
-                    EEH_Inflector::pluralize_and_lower(self::getResourceName()),
38
-                    $required_permission
39
-                )
40
-            );
41
-        }
42
-    }
19
+	/**
20
+	 * @param $required_permission
21
+	 * @param $attempted_calculation
22
+	 * @throws \EventEspresso\core\libraries\rest_api\RestException
23
+	 */
24
+	protected static function verifyCurrentUserCan($required_permission, $attempted_calculation)
25
+	{
26
+		if (! current_user_can($required_permission)) {
27
+			throw new RestException(
28
+				'permission_denied',
29
+				sprintf(
30
+					__(
31
+					// @codingStandardsIgnoreStart
32
+						'Permission denied, you cannot calculate %1$s on %2$s because you do not have the capability "%3$s"',
33
+						// @codingStandardsIgnoreEnd
34
+						'event_espresso'
35
+					),
36
+					$attempted_calculation,
37
+					EEH_Inflector::pluralize_and_lower(self::getResourceName()),
38
+					$required_permission
39
+				)
40
+			);
41
+		}
42
+	}
43 43
 
44 44
 
45
-    /**
46
-     * Gets the name of the resource of the called class
47
-     *
48
-     * @return string
49
-     */
50
-    public static function getResourceName()
51
-    {
52
-        $classname = get_called_class();
53
-        return substr($classname, strrpos($classname, '\\') + 1);
54
-    }
45
+	/**
46
+	 * Gets the name of the resource of the called class
47
+	 *
48
+	 * @return string
49
+	 */
50
+	public static function getResourceName()
51
+	{
52
+		$classname = get_called_class();
53
+		return substr($classname, strrpos($classname, '\\') + 1);
54
+	}
55 55
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
      */
24 24
     protected static function verifyCurrentUserCan($required_permission, $attempted_calculation)
25 25
     {
26
-        if (! current_user_can($required_permission)) {
26
+        if ( ! current_user_can($required_permission)) {
27 27
             throw new RestException(
28 28
                 'permission_denied',
29 29
                 sprintf(
Please login to merge, or discard this patch.
core/libraries/rest_api/calculations/Datetime.php 2 patches
Indentation   +131 added lines, -131 removed lines patch added patch discarded remove patch
@@ -11,141 +11,141 @@
 block discarded – undo
11 11
 class Datetime extends Calculations_Base
12 12
 {
13 13
 
14
-    /**
15
-     * Calculates the total spaces available on the datetime, taking into account
16
-     * ticket limits too.
17
-     *
18
-     * @see EE_Datetime::spaces_remaining( true )
19
-     * @param array            $wpdb_row
20
-     * @param \WP_REST_Request $request
21
-     * @param Controller_Base  $controller
22
-     * @return int
23
-     * @throws \EE_Error
24
-     */
25
-    public static function spacesRemainingConsideringTickets($wpdb_row, $request, $controller)
26
-    {
27
-        if (is_array($wpdb_row) && isset($wpdb_row['Datetime.DTT_ID'])) {
28
-            $dtt_obj = EEM_Datetime::instance()->get_one_by_ID($wpdb_row['Datetime.DTT_ID']);
29
-        } else {
30
-            $dtt_obj = null;
31
-        }
32
-        if ($dtt_obj instanceof EE_Datetime) {
33
-            return $dtt_obj->spaces_remaining(true);
34
-        } else {
35
-            throw new \EE_Error(
36
-                sprintf(
37
-                    __(
38
-                    // @codingStandardsIgnoreStart
39
-                        'Cannot calculate spaces_remaining_considering_tickets because the datetime with ID %1$s (from database row %2$s) was not found',
40
-                        // @codingStandardsIgnoreEnd
41
-                        'event_espresso'
42
-                    ),
43
-                    $wpdb_row['Datetime.DTT_ID'],
44
-                    print_r($wpdb_row, true)
45
-                )
46
-            );
47
-        }
48
-    }
14
+	/**
15
+	 * Calculates the total spaces available on the datetime, taking into account
16
+	 * ticket limits too.
17
+	 *
18
+	 * @see EE_Datetime::spaces_remaining( true )
19
+	 * @param array            $wpdb_row
20
+	 * @param \WP_REST_Request $request
21
+	 * @param Controller_Base  $controller
22
+	 * @return int
23
+	 * @throws \EE_Error
24
+	 */
25
+	public static function spacesRemainingConsideringTickets($wpdb_row, $request, $controller)
26
+	{
27
+		if (is_array($wpdb_row) && isset($wpdb_row['Datetime.DTT_ID'])) {
28
+			$dtt_obj = EEM_Datetime::instance()->get_one_by_ID($wpdb_row['Datetime.DTT_ID']);
29
+		} else {
30
+			$dtt_obj = null;
31
+		}
32
+		if ($dtt_obj instanceof EE_Datetime) {
33
+			return $dtt_obj->spaces_remaining(true);
34
+		} else {
35
+			throw new \EE_Error(
36
+				sprintf(
37
+					__(
38
+					// @codingStandardsIgnoreStart
39
+						'Cannot calculate spaces_remaining_considering_tickets because the datetime with ID %1$s (from database row %2$s) was not found',
40
+						// @codingStandardsIgnoreEnd
41
+						'event_espresso'
42
+					),
43
+					$wpdb_row['Datetime.DTT_ID'],
44
+					print_r($wpdb_row, true)
45
+				)
46
+			);
47
+		}
48
+	}
49 49
 
50 50
 
51
-    /**
52
-     * Counts registrations who have checked into this datetime
53
-     *
54
-     * @param array            $wpdb_row
55
-     * @param \WP_REST_Request $request
56
-     * @param Controller_Base  $controller
57
-     * @return int
58
-     * @throws \EE_Error
59
-     * @throws \EventEspresso\core\libraries\rest_api\RestException
60
-     */
61
-    public static function registrationsCheckedInCount($wpdb_row, $request, $controller)
62
-    {
63
-        if (! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) {
64
-            throw new \EE_Error(
65
-                sprintf(
66
-                    __(
67
-                    // @codingStandardsIgnoreStart
68
-                        'Cannot calculate registrations_checked_in_count because the database row %1$s does not have an entry for "Datetime.DTT_ID"',
69
-                        // @codingStandardsIgnoreEnd
70
-                        'event_espresso'
71
-                    ),
72
-                    print_r($wpdb_row, true)
73
-                )
74
-            );
75
-        }
76
-        self::verifyCurrentUserCan('ee_read_checkins', 'registrations_checked_in_count');
77
-        return EEM_Registration::instance()
78
-                               ->count_registrations_checked_into_datetime($wpdb_row['Datetime.DTT_ID'], true);
79
-    }
51
+	/**
52
+	 * Counts registrations who have checked into this datetime
53
+	 *
54
+	 * @param array            $wpdb_row
55
+	 * @param \WP_REST_Request $request
56
+	 * @param Controller_Base  $controller
57
+	 * @return int
58
+	 * @throws \EE_Error
59
+	 * @throws \EventEspresso\core\libraries\rest_api\RestException
60
+	 */
61
+	public static function registrationsCheckedInCount($wpdb_row, $request, $controller)
62
+	{
63
+		if (! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) {
64
+			throw new \EE_Error(
65
+				sprintf(
66
+					__(
67
+					// @codingStandardsIgnoreStart
68
+						'Cannot calculate registrations_checked_in_count because the database row %1$s does not have an entry for "Datetime.DTT_ID"',
69
+						// @codingStandardsIgnoreEnd
70
+						'event_espresso'
71
+					),
72
+					print_r($wpdb_row, true)
73
+				)
74
+			);
75
+		}
76
+		self::verifyCurrentUserCan('ee_read_checkins', 'registrations_checked_in_count');
77
+		return EEM_Registration::instance()
78
+							   ->count_registrations_checked_into_datetime($wpdb_row['Datetime.DTT_ID'], true);
79
+	}
80 80
 
81 81
 
82
-    /**
83
-     * Counts registrations who have checked out of this datetime
84
-     *
85
-     * @param array            $wpdb_row
86
-     * @param \WP_REST_Request $request
87
-     * @param Controller_Base  $controller
88
-     * @return int
89
-     * @throws \EE_Error
90
-     * @throws \EventEspresso\core\libraries\rest_api\RestException
91
-     */
92
-    public static function registrationsCheckedOutCount($wpdb_row, $request, $controller)
93
-    {
94
-        if (! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) {
95
-            throw new \EE_Error(
96
-                sprintf(
97
-                    __(
98
-                    // @codingStandardsIgnoreStart
99
-                        'Cannot calculate registrations_checked_out_count because the database row %1$s does not have an entry for "Datetime.DTT_ID"',
100
-                        // @codingStandardsIgnoreEnd
101
-                        'event_espresso'
102
-                    ),
103
-                    print_r($wpdb_row, true)
104
-                )
105
-            );
106
-        }
107
-        self::verifyCurrentUserCan('ee_read_checkins', 'registrations_checked_out_count');
108
-        return EEM_Registration::instance()
109
-                               ->count_registrations_checked_into_datetime($wpdb_row['Datetime.DTT_ID'], false);
110
-    }
82
+	/**
83
+	 * Counts registrations who have checked out of this datetime
84
+	 *
85
+	 * @param array            $wpdb_row
86
+	 * @param \WP_REST_Request $request
87
+	 * @param Controller_Base  $controller
88
+	 * @return int
89
+	 * @throws \EE_Error
90
+	 * @throws \EventEspresso\core\libraries\rest_api\RestException
91
+	 */
92
+	public static function registrationsCheckedOutCount($wpdb_row, $request, $controller)
93
+	{
94
+		if (! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) {
95
+			throw new \EE_Error(
96
+				sprintf(
97
+					__(
98
+					// @codingStandardsIgnoreStart
99
+						'Cannot calculate registrations_checked_out_count because the database row %1$s does not have an entry for "Datetime.DTT_ID"',
100
+						// @codingStandardsIgnoreEnd
101
+						'event_espresso'
102
+					),
103
+					print_r($wpdb_row, true)
104
+				)
105
+			);
106
+		}
107
+		self::verifyCurrentUserCan('ee_read_checkins', 'registrations_checked_out_count');
108
+		return EEM_Registration::instance()
109
+							   ->count_registrations_checked_into_datetime($wpdb_row['Datetime.DTT_ID'], false);
110
+	}
111 111
 
112 112
 
113
-    /**
114
-     * Counts the number of pending-payment registrations for this event (regardless
115
-     * of how many datetimes each registrations' ticket purchase is for)
116
-     *
117
-     * @param array            $wpdb_row
118
-     * @param \WP_REST_Request $request
119
-     * @param Controller_Base  $controller
120
-     * @return int
121
-     * @throws \EE_Error
122
-     * @throws \EventEspresso\core\libraries\rest_api\RestException
123
-     */
124
-    public static function spotsTakenPendingPayment($wpdb_row, $request, $controller)
125
-    {
126
-        if (! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) {
127
-            throw new \EE_Error(
128
-                sprintf(
129
-                    __(
130
-                    // @codingStandardsIgnoreStart
131
-                        'Cannot calculate spots_taken_pending_payment because the database row %1$s does not have an entry for "Datetime.DTT_ID"',
132
-                        // @codingStandardsIgnoreEnd
133
-                        'event_espresso'
134
-                    ),
135
-                    print_r($wpdb_row, true)
136
-                )
137
-            );
138
-        }
139
-        self::verifyCurrentUserCan('ee_read_registrations', 'spots_taken_pending_payment');
140
-        return EEM_Registration::instance()->count(
141
-            array(
142
-                array(
143
-                    'Ticket.Datetime.DTT_ID' => $wpdb_row['Datetime.DTT_ID'],
144
-                    'STS_ID'                 => EEM_Registration::status_id_pending_payment,
145
-                ),
146
-            ),
147
-            'REG_ID',
148
-            true
149
-        );
150
-    }
113
+	/**
114
+	 * Counts the number of pending-payment registrations for this event (regardless
115
+	 * of how many datetimes each registrations' ticket purchase is for)
116
+	 *
117
+	 * @param array            $wpdb_row
118
+	 * @param \WP_REST_Request $request
119
+	 * @param Controller_Base  $controller
120
+	 * @return int
121
+	 * @throws \EE_Error
122
+	 * @throws \EventEspresso\core\libraries\rest_api\RestException
123
+	 */
124
+	public static function spotsTakenPendingPayment($wpdb_row, $request, $controller)
125
+	{
126
+		if (! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) {
127
+			throw new \EE_Error(
128
+				sprintf(
129
+					__(
130
+					// @codingStandardsIgnoreStart
131
+						'Cannot calculate spots_taken_pending_payment because the database row %1$s does not have an entry for "Datetime.DTT_ID"',
132
+						// @codingStandardsIgnoreEnd
133
+						'event_espresso'
134
+					),
135
+					print_r($wpdb_row, true)
136
+				)
137
+			);
138
+		}
139
+		self::verifyCurrentUserCan('ee_read_registrations', 'spots_taken_pending_payment');
140
+		return EEM_Registration::instance()->count(
141
+			array(
142
+				array(
143
+					'Ticket.Datetime.DTT_ID' => $wpdb_row['Datetime.DTT_ID'],
144
+					'STS_ID'                 => EEM_Registration::status_id_pending_payment,
145
+				),
146
+			),
147
+			'REG_ID',
148
+			true
149
+		);
150
+	}
151 151
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
      */
61 61
     public static function registrationsCheckedInCount($wpdb_row, $request, $controller)
62 62
     {
63
-        if (! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) {
63
+        if ( ! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) {
64 64
             throw new \EE_Error(
65 65
                 sprintf(
66 66
                     __(
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      */
92 92
     public static function registrationsCheckedOutCount($wpdb_row, $request, $controller)
93 93
     {
94
-        if (! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) {
94
+        if ( ! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) {
95 95
             throw new \EE_Error(
96 96
                 sprintf(
97 97
                     __(
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
      */
124 124
     public static function spotsTakenPendingPayment($wpdb_row, $request, $controller)
125 125
     {
126
-        if (! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) {
126
+        if ( ! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) {
127 127
             throw new \EE_Error(
128 128
                 sprintf(
129 129
                     __(
Please login to merge, or discard this patch.