Completed
Branch ADMIN-REFRESH (41ec76)
by
unknown
03:25 queued 28s
created
core/db_classes/EE_Registration.class.php 2 patches
Indentation   +2112 added lines, -2112 removed lines patch added patch discarded remove patch
@@ -17,2116 +17,2116 @@
 block discarded – undo
17 17
 {
18 18
 
19 19
 
20
-    /**
21
-     * Used to reference when a registration has never been checked in.
22
-     *
23
-     * @deprecated use \EE_Checkin::status_checked_never instead
24
-     * @type int
25
-     */
26
-    const checkin_status_never = 2;
27
-
28
-    /**
29
-     * Used to reference when a registration has been checked in.
30
-     *
31
-     * @deprecated use \EE_Checkin::status_checked_in instead
32
-     * @type int
33
-     */
34
-    const checkin_status_in = 1;
35
-
36
-
37
-    /**
38
-     * Used to reference when a registration has been checked out.
39
-     *
40
-     * @deprecated use \EE_Checkin::status_checked_out instead
41
-     * @type int
42
-     */
43
-    const checkin_status_out = 0;
44
-
45
-
46
-    /**
47
-     * extra meta key for tracking reg status os trashed registrations
48
-     *
49
-     * @type string
50
-     */
51
-    const PRE_TRASH_REG_STATUS_KEY = 'pre_trash_registration_status';
52
-
53
-
54
-    /**
55
-     * extra meta key for tracking if registration has reserved ticket
56
-     *
57
-     * @type string
58
-     */
59
-    const HAS_RESERVED_TICKET_KEY = 'has_reserved_ticket';
60
-
61
-
62
-    /**
63
-     * @param array  $props_n_values          incoming values
64
-     * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
65
-     *                                        used.)
66
-     * @param array  $date_formats            incoming date_formats in an array where the first value is the
67
-     *                                        date_format and the second value is the time format
68
-     * @return EE_Registration
69
-     * @throws EE_Error
70
-     */
71
-    public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
72
-    {
73
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
74
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
75
-    }
76
-
77
-
78
-    /**
79
-     * @param array  $props_n_values  incoming values from the database
80
-     * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
81
-     *                                the website will be used.
82
-     * @return EE_Registration
83
-     */
84
-    public static function new_instance_from_db($props_n_values = array(), $timezone = null)
85
-    {
86
-        return new self($props_n_values, true, $timezone);
87
-    }
88
-
89
-
90
-    /**
91
-     *        Set Event ID
92
-     *
93
-     * @param        int $EVT_ID Event ID
94
-     * @throws EE_Error
95
-     * @throws RuntimeException
96
-     */
97
-    public function set_event($EVT_ID = 0)
98
-    {
99
-        $this->set('EVT_ID', $EVT_ID);
100
-    }
101
-
102
-
103
-    /**
104
-     * Overrides parent set() method so that all calls to set( 'REG_code', $REG_code ) OR set( 'STS_ID', $STS_ID ) can
105
-     * be routed to internal methods
106
-     *
107
-     * @param string $field_name
108
-     * @param mixed  $field_value
109
-     * @param bool   $use_default
110
-     * @throws EE_Error
111
-     * @throws EntityNotFoundException
112
-     * @throws InvalidArgumentException
113
-     * @throws InvalidDataTypeException
114
-     * @throws InvalidInterfaceException
115
-     * @throws ReflectionException
116
-     * @throws RuntimeException
117
-     */
118
-    public function set($field_name, $field_value, $use_default = false)
119
-    {
120
-        switch ($field_name) {
121
-            case 'REG_code':
122
-                if (! empty($field_value) && $this->reg_code() === null) {
123
-                    $this->set_reg_code($field_value, $use_default);
124
-                }
125
-                break;
126
-            case 'STS_ID':
127
-                $this->set_status($field_value, $use_default);
128
-                break;
129
-            default:
130
-                parent::set($field_name, $field_value, $use_default);
131
-        }
132
-    }
133
-
134
-
135
-    /**
136
-     * Set Status ID
137
-     * updates the registration status and ALSO...
138
-     * calls reserve_registration_space() if the reg status changes TO approved from any other reg status
139
-     * calls release_registration_space() if the reg status changes FROM approved to any other reg status
140
-     *
141
-     * @param string                $new_STS_ID
142
-     * @param boolean               $use_default
143
-     * @param ContextInterface|null $context
144
-     * @return bool
145
-     * @throws DomainException
146
-     * @throws EE_Error
147
-     * @throws EntityNotFoundException
148
-     * @throws InvalidArgumentException
149
-     * @throws InvalidDataTypeException
150
-     * @throws InvalidInterfaceException
151
-     * @throws ReflectionException
152
-     * @throws RuntimeException
153
-     * @throws UnexpectedEntityException
154
-     */
155
-    public function set_status($new_STS_ID = null, $use_default = false, ContextInterface $context = null)
156
-    {
157
-        // get current REG_Status
158
-        $old_STS_ID = $this->status_ID();
159
-        // if status has changed
160
-        if (
161
-            $old_STS_ID !== $new_STS_ID // and that status has actually changed
162
-            && ! empty($old_STS_ID) // and that old status is actually set
163
-            && ! empty($new_STS_ID) // as well as the new status
164
-            && $this->ID() // ensure registration is in the db
165
-        ) {
166
-            // update internal status first
167
-            parent::set('STS_ID', $new_STS_ID, $use_default);
168
-            // THEN handle other changes that occur when reg status changes
169
-            // TO approved
170
-            if ($new_STS_ID === EEM_Registration::status_id_approved) {
171
-                // reserve a space by incrementing ticket and datetime sold values
172
-                $this->reserveRegistrationSpace();
173
-                do_action('AHEE__EE_Registration__set_status__to_approved', $this, $old_STS_ID, $new_STS_ID, $context);
174
-                // OR FROM  approved
175
-            } elseif ($old_STS_ID === EEM_Registration::status_id_approved) {
176
-                // release a space by decrementing ticket and datetime sold values
177
-                $this->releaseRegistrationSpace();
178
-                do_action(
179
-                    'AHEE__EE_Registration__set_status__from_approved',
180
-                    $this,
181
-                    $old_STS_ID,
182
-                    $new_STS_ID,
183
-                    $context
184
-                );
185
-            }
186
-            // update status
187
-            parent::set('STS_ID', $new_STS_ID, $use_default);
188
-            $this->updateIfCanceledOrReinstated($new_STS_ID, $old_STS_ID, $context);
189
-            if ($this->statusChangeUpdatesTransaction($context)) {
190
-                $this->updateTransactionAfterStatusChange();
191
-            }
192
-            do_action('AHEE__EE_Registration__set_status__after_update', $this, $old_STS_ID, $new_STS_ID, $context);
193
-            return true;
194
-        }
195
-        // even though the old value matches the new value, it's still good to
196
-        // allow the parent set method to have a say
197
-        parent::set('STS_ID', $new_STS_ID, $use_default);
198
-        return true;
199
-    }
200
-
201
-
202
-    /**
203
-     * update REGs and TXN when cancelled or declined registrations involved
204
-     *
205
-     * @param string                $new_STS_ID
206
-     * @param string                $old_STS_ID
207
-     * @param ContextInterface|null $context
208
-     * @throws EE_Error
209
-     * @throws InvalidArgumentException
210
-     * @throws InvalidDataTypeException
211
-     * @throws InvalidInterfaceException
212
-     * @throws ReflectionException
213
-     * @throws RuntimeException
214
-     */
215
-    private function updateIfCanceledOrReinstated($new_STS_ID, $old_STS_ID, ContextInterface $context = null)
216
-    {
217
-        // these reg statuses should not be considered in any calculations involving monies owing
218
-        $closed_reg_statuses = EEM_Registration::closed_reg_statuses();
219
-        // true if registration has been cancelled or declined
220
-        $this->updateIfCanceled(
221
-            $closed_reg_statuses,
222
-            $new_STS_ID,
223
-            $old_STS_ID,
224
-            $context
225
-        );
226
-        $this->updateIfReinstated(
227
-            $closed_reg_statuses,
228
-            $new_STS_ID,
229
-            $old_STS_ID,
230
-            $context
231
-        );
232
-    }
233
-
234
-
235
-    /**
236
-     * update REGs and TXN when cancelled or declined registrations involved
237
-     *
238
-     * @param array                 $closed_reg_statuses
239
-     * @param string                $new_STS_ID
240
-     * @param string                $old_STS_ID
241
-     * @param ContextInterface|null $context
242
-     * @throws EE_Error
243
-     * @throws InvalidArgumentException
244
-     * @throws InvalidDataTypeException
245
-     * @throws InvalidInterfaceException
246
-     * @throws ReflectionException
247
-     * @throws RuntimeException
248
-     */
249
-    private function updateIfCanceled(
250
-        array $closed_reg_statuses,
251
-        $new_STS_ID,
252
-        $old_STS_ID,
253
-        ContextInterface $context = null
254
-    ) {
255
-        // true if registration has been cancelled or declined
256
-        if (
257
-            in_array($new_STS_ID, $closed_reg_statuses, true)
258
-            && ! in_array($old_STS_ID, $closed_reg_statuses, true)
259
-        ) {
260
-            /** @type EE_Registration_Processor $registration_processor */
261
-            $registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
262
-            /** @type EE_Transaction_Processor $transaction_processor */
263
-            $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
264
-            // cancelled or declined registration
265
-            $registration_processor->update_registration_after_being_canceled_or_declined(
266
-                $this,
267
-                $closed_reg_statuses
268
-            );
269
-            $transaction_processor->update_transaction_after_canceled_or_declined_registration(
270
-                $this,
271
-                $closed_reg_statuses,
272
-                false
273
-            );
274
-            do_action(
275
-                'AHEE__EE_Registration__set_status__canceled_or_declined',
276
-                $this,
277
-                $old_STS_ID,
278
-                $new_STS_ID,
279
-                $context
280
-            );
281
-            return;
282
-        }
283
-    }
284
-
285
-
286
-    /**
287
-     * update REGs and TXN when cancelled or declined registrations involved
288
-     *
289
-     * @param array                 $closed_reg_statuses
290
-     * @param string                $new_STS_ID
291
-     * @param string                $old_STS_ID
292
-     * @param ContextInterface|null $context
293
-     * @throws EE_Error
294
-     * @throws InvalidArgumentException
295
-     * @throws InvalidDataTypeException
296
-     * @throws InvalidInterfaceException
297
-     * @throws ReflectionException
298
-     */
299
-    private function updateIfReinstated(
300
-        array $closed_reg_statuses,
301
-        $new_STS_ID,
302
-        $old_STS_ID,
303
-        ContextInterface $context = null
304
-    ) {
305
-        // true if reinstating cancelled or declined registration
306
-        if (
307
-            in_array($old_STS_ID, $closed_reg_statuses, true)
308
-            && ! in_array($new_STS_ID, $closed_reg_statuses, true)
309
-        ) {
310
-            /** @type EE_Registration_Processor $registration_processor */
311
-            $registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
312
-            /** @type EE_Transaction_Processor $transaction_processor */
313
-            $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
314
-            // reinstating cancelled or declined registration
315
-            $registration_processor->update_canceled_or_declined_registration_after_being_reinstated(
316
-                $this,
317
-                $closed_reg_statuses
318
-            );
319
-            $transaction_processor->update_transaction_after_reinstating_canceled_registration(
320
-                $this,
321
-                $closed_reg_statuses,
322
-                false
323
-            );
324
-            do_action(
325
-                'AHEE__EE_Registration__set_status__after_reinstated',
326
-                $this,
327
-                $old_STS_ID,
328
-                $new_STS_ID,
329
-                $context
330
-            );
331
-        }
332
-    }
333
-
334
-
335
-    /**
336
-     * @param ContextInterface|null $context
337
-     * @return bool
338
-     */
339
-    private function statusChangeUpdatesTransaction(ContextInterface $context = null)
340
-    {
341
-        $contexts_that_do_not_update_transaction = (array) apply_filters(
342
-            'AHEE__EE_Registration__statusChangeUpdatesTransaction__contexts_that_do_not_update_transaction',
343
-            array('spco_reg_step_attendee_information_process_registrations'),
344
-            $context,
345
-            $this
346
-        );
347
-        return ! (
348
-            $context instanceof ContextInterface
349
-            && in_array($context->slug(), $contexts_that_do_not_update_transaction, true)
350
-        );
351
-    }
352
-
353
-
354
-    /**
355
-     * @throws EE_Error
356
-     * @throws EntityNotFoundException
357
-     * @throws InvalidArgumentException
358
-     * @throws InvalidDataTypeException
359
-     * @throws InvalidInterfaceException
360
-     * @throws ReflectionException
361
-     * @throws RuntimeException
362
-     */
363
-    private function updateTransactionAfterStatusChange()
364
-    {
365
-        /** @type EE_Transaction_Payments $transaction_payments */
366
-        $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
367
-        $transaction_payments->recalculate_transaction_total($this->transaction(), false);
368
-        $this->transaction()->update_status_based_on_total_paid(true);
369
-    }
370
-
371
-
372
-    /**
373
-     *        get Status ID
374
-     */
375
-    public function status_ID()
376
-    {
377
-        return $this->get('STS_ID');
378
-    }
379
-
380
-
381
-    /**
382
-     * Gets the ticket this registration is for
383
-     *
384
-     * @param boolean $include_archived whether to include archived tickets or not.
385
-     *
386
-     * @return EE_Ticket|EE_Base_Class
387
-     * @throws EE_Error
388
-     */
389
-    public function ticket($include_archived = true)
390
-    {
391
-        $query_params = array();
392
-        if ($include_archived) {
393
-            $query_params['default_where_conditions'] = 'none';
394
-        }
395
-        return $this->get_first_related('Ticket', $query_params);
396
-    }
397
-
398
-
399
-    /**
400
-     * Gets the event this registration is for
401
-     *
402
-     * @return EE_Event
403
-     * @throws EE_Error
404
-     * @throws EntityNotFoundException
405
-     */
406
-    public function event()
407
-    {
408
-        $event = $this->get_first_related('Event');
409
-        if (! $event instanceof \EE_Event) {
410
-            throw new EntityNotFoundException('Event ID', $this->event_ID());
411
-        }
412
-        return $event;
413
-    }
414
-
415
-
416
-    /**
417
-     * Gets the "author" of the registration.  Note that for the purposes of registrations, the author will correspond
418
-     * with the author of the event this registration is for.
419
-     *
420
-     * @since 4.5.0
421
-     * @return int
422
-     * @throws EE_Error
423
-     * @throws EntityNotFoundException
424
-     */
425
-    public function wp_user()
426
-    {
427
-        $event = $this->event();
428
-        if ($event instanceof EE_Event) {
429
-            return $event->wp_user();
430
-        }
431
-        return 0;
432
-    }
433
-
434
-
435
-    /**
436
-     * increments this registration's related ticket sold and corresponding datetime sold values
437
-     *
438
-     * @return void
439
-     * @throws DomainException
440
-     * @throws EE_Error
441
-     * @throws EntityNotFoundException
442
-     * @throws InvalidArgumentException
443
-     * @throws InvalidDataTypeException
444
-     * @throws InvalidInterfaceException
445
-     * @throws ReflectionException
446
-     * @throws UnexpectedEntityException
447
-     */
448
-    private function reserveRegistrationSpace()
449
-    {
450
-        // reserved ticket and datetime counts will be decremented as sold counts are incremented
451
-        // so stop tracking that this reg has a ticket reserved
452
-        $this->release_reserved_ticket(false, "REG: {$this->ID()} (ln:" . __LINE__ . ')');
453
-        $ticket = $this->ticket();
454
-        $ticket->increaseSold();
455
-        // possibly set event status to sold out
456
-        $this->event()->perform_sold_out_status_check();
457
-    }
458
-
459
-
460
-    /**
461
-     * decrements (subtracts) this registration's related ticket sold and corresponding datetime sold values
462
-     *
463
-     * @return void
464
-     * @throws DomainException
465
-     * @throws EE_Error
466
-     * @throws EntityNotFoundException
467
-     * @throws InvalidArgumentException
468
-     * @throws InvalidDataTypeException
469
-     * @throws InvalidInterfaceException
470
-     * @throws ReflectionException
471
-     * @throws UnexpectedEntityException
472
-     */
473
-    private function releaseRegistrationSpace()
474
-    {
475
-        $ticket = $this->ticket();
476
-        $ticket->decreaseSold();
477
-        // possibly change event status from sold out back to previous status
478
-        $this->event()->perform_sold_out_status_check();
479
-    }
480
-
481
-
482
-    /**
483
-     * tracks this registration's ticket reservation in extra meta
484
-     * and can increment related ticket reserved and corresponding datetime reserved values
485
-     *
486
-     * @param bool $update_ticket if true, will increment ticket and datetime reserved count
487
-     * @return void
488
-     * @throws EE_Error
489
-     * @throws InvalidArgumentException
490
-     * @throws InvalidDataTypeException
491
-     * @throws InvalidInterfaceException
492
-     * @throws ReflectionException
493
-     */
494
-    public function reserve_ticket($update_ticket = false, $source = 'unknown')
495
-    {
496
-        // only reserve ticket if space is not currently reserved
497
-        if ((bool) $this->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true) !== true) {
498
-            $this->update_extra_meta('reserve_ticket', "{$this->ticket_ID()} from {$source}");
499
-            // IMPORTANT !!!
500
-            // although checking $update_ticket first would be more efficient,
501
-            // we NEED to ALWAYS call update_extra_meta(), which is why that is done first
502
-            if (
503
-                $this->update_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true)
504
-                && $update_ticket
505
-            ) {
506
-                $ticket = $this->ticket();
507
-                $ticket->increaseReserved(1, "REG: {$this->ID()} (ln:" . __LINE__ . ')');
508
-                $ticket->save();
509
-            }
510
-        }
511
-    }
512
-
513
-
514
-    /**
515
-     * stops tracking this registration's ticket reservation in extra meta
516
-     * decrements (subtracts) related ticket reserved and corresponding datetime reserved values
517
-     *
518
-     * @param bool $update_ticket if true, will decrement ticket and datetime reserved count
519
-     * @return void
520
-     * @throws EE_Error
521
-     * @throws InvalidArgumentException
522
-     * @throws InvalidDataTypeException
523
-     * @throws InvalidInterfaceException
524
-     * @throws ReflectionException
525
-     */
526
-    public function release_reserved_ticket($update_ticket = false, $source = 'unknown')
527
-    {
528
-        // only release ticket if space is currently reserved
529
-        if ((bool) $this->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true) === true) {
530
-            $this->update_extra_meta('release_reserved_ticket', "{$this->ticket_ID()} from {$source}");
531
-            // IMPORTANT !!!
532
-            // although checking $update_ticket first would be more efficient,
533
-            // we NEED to ALWAYS call update_extra_meta(), which is why that is done first
534
-            if (
535
-                $this->update_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, false)
536
-                && $update_ticket
537
-            ) {
538
-                $ticket = $this->ticket();
539
-                $ticket->decreaseReserved(1, true, "REG: {$this->ID()} (ln:" . __LINE__ . ')');
540
-            }
541
-        }
542
-    }
543
-
544
-
545
-    /**
546
-     * Set Attendee ID
547
-     *
548
-     * @param        int $ATT_ID Attendee ID
549
-     * @throws EE_Error
550
-     * @throws RuntimeException
551
-     */
552
-    public function set_attendee_id($ATT_ID = 0)
553
-    {
554
-        $this->set('ATT_ID', $ATT_ID);
555
-    }
556
-
557
-
558
-    /**
559
-     *        Set Transaction ID
560
-     *
561
-     * @param        int $TXN_ID Transaction ID
562
-     * @throws EE_Error
563
-     * @throws RuntimeException
564
-     */
565
-    public function set_transaction_id($TXN_ID = 0)
566
-    {
567
-        $this->set('TXN_ID', $TXN_ID);
568
-    }
569
-
570
-
571
-    /**
572
-     *        Set Session
573
-     *
574
-     * @param    string $REG_session PHP Session ID
575
-     * @throws EE_Error
576
-     * @throws RuntimeException
577
-     */
578
-    public function set_session($REG_session = '')
579
-    {
580
-        $this->set('REG_session', $REG_session);
581
-    }
582
-
583
-
584
-    /**
585
-     *        Set Registration URL Link
586
-     *
587
-     * @param    string $REG_url_link Registration URL Link
588
-     * @throws EE_Error
589
-     * @throws RuntimeException
590
-     */
591
-    public function set_reg_url_link($REG_url_link = '')
592
-    {
593
-        $this->set('REG_url_link', $REG_url_link);
594
-    }
595
-
596
-
597
-    /**
598
-     *        Set Attendee Counter
599
-     *
600
-     * @param        int $REG_count Primary Attendee
601
-     * @throws EE_Error
602
-     * @throws RuntimeException
603
-     */
604
-    public function set_count($REG_count = 1)
605
-    {
606
-        $this->set('REG_count', $REG_count);
607
-    }
608
-
609
-
610
-    /**
611
-     *        Set Group Size
612
-     *
613
-     * @param        boolean $REG_group_size Group Registration
614
-     * @throws EE_Error
615
-     * @throws RuntimeException
616
-     */
617
-    public function set_group_size($REG_group_size = false)
618
-    {
619
-        $this->set('REG_group_size', $REG_group_size);
620
-    }
621
-
622
-
623
-    /**
624
-     *    is_not_approved -  convenience method that returns TRUE if REG status ID ==
625
-     *    EEM_Registration::status_id_not_approved
626
-     *
627
-     * @return        boolean
628
-     */
629
-    public function is_not_approved()
630
-    {
631
-        return $this->status_ID() == EEM_Registration::status_id_not_approved ? true : false;
632
-    }
633
-
634
-
635
-    /**
636
-     *    is_pending_payment -  convenience method that returns TRUE if REG status ID ==
637
-     *    EEM_Registration::status_id_pending_payment
638
-     *
639
-     * @return        boolean
640
-     */
641
-    public function is_pending_payment()
642
-    {
643
-        return $this->status_ID() == EEM_Registration::status_id_pending_payment ? true : false;
644
-    }
645
-
646
-
647
-    /**
648
-     *    is_approved -  convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_approved
649
-     *
650
-     * @return        boolean
651
-     */
652
-    public function is_approved()
653
-    {
654
-        return $this->status_ID() == EEM_Registration::status_id_approved ? true : false;
655
-    }
656
-
657
-
658
-    /**
659
-     *    is_cancelled -  convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_cancelled
660
-     *
661
-     * @return        boolean
662
-     */
663
-    public function is_cancelled()
664
-    {
665
-        return $this->status_ID() == EEM_Registration::status_id_cancelled ? true : false;
666
-    }
667
-
668
-
669
-    /**
670
-     *    is_declined -  convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_declined
671
-     *
672
-     * @return        boolean
673
-     */
674
-    public function is_declined()
675
-    {
676
-        return $this->status_ID() == EEM_Registration::status_id_declined ? true : false;
677
-    }
678
-
679
-
680
-    /**
681
-     *    is_incomplete -  convenience method that returns TRUE if REG status ID ==
682
-     *    EEM_Registration::status_id_incomplete
683
-     *
684
-     * @return        boolean
685
-     */
686
-    public function is_incomplete()
687
-    {
688
-        return $this->status_ID() == EEM_Registration::status_id_incomplete ? true : false;
689
-    }
690
-
691
-
692
-    /**
693
-     *        Set Registration Date
694
-     *
695
-     * @param        mixed ( int or string ) $REG_date Registration Date - Unix timestamp or string representation of
696
-     *                                                 Date
697
-     * @throws EE_Error
698
-     * @throws RuntimeException
699
-     */
700
-    public function set_reg_date($REG_date = false)
701
-    {
702
-        $this->set('REG_date', $REG_date);
703
-    }
704
-
705
-
706
-    /**
707
-     *    Set final price owing for this registration after all ticket/price modifications
708
-     *
709
-     * @access    public
710
-     * @param    float $REG_final_price
711
-     * @throws EE_Error
712
-     * @throws RuntimeException
713
-     */
714
-    public function set_final_price($REG_final_price = 0.00)
715
-    {
716
-        $this->set('REG_final_price', $REG_final_price);
717
-    }
718
-
719
-
720
-    /**
721
-     *    Set amount paid towards this registration's final price
722
-     *
723
-     * @access    public
724
-     * @param    float $REG_paid
725
-     * @throws EE_Error
726
-     * @throws RuntimeException
727
-     */
728
-    public function set_paid($REG_paid = 0.00)
729
-    {
730
-        $this->set('REG_paid', $REG_paid);
731
-    }
732
-
733
-
734
-    /**
735
-     *        Attendee Is Going
736
-     *
737
-     * @param        boolean $REG_att_is_going Attendee Is Going
738
-     * @throws EE_Error
739
-     * @throws RuntimeException
740
-     */
741
-    public function set_att_is_going($REG_att_is_going = false)
742
-    {
743
-        $this->set('REG_att_is_going', $REG_att_is_going);
744
-    }
745
-
746
-
747
-    /**
748
-     * Gets the related attendee
749
-     *
750
-     * @return EE_Attendee
751
-     * @throws EE_Error
752
-     */
753
-    public function attendee()
754
-    {
755
-        return $this->get_first_related('Attendee');
756
-    }
757
-
758
-    /**
759
-     * Gets the name of the attendee.
760
-     * @since 4.10.12.p
761
-     * @param bool $apply_html_entities set to true if you want to use HTML entities.
762
-     * @return string
763
-     * @throws EE_Error
764
-     * @throws InvalidArgumentException
765
-     * @throws InvalidDataTypeException
766
-     * @throws InvalidInterfaceException
767
-     * @throws ReflectionException
768
-     */
769
-    public function attendeeName($apply_html_entities = false)
770
-    {
771
-        $attendee = $this->get_first_related('Attendee');
772
-        if ($attendee instanceof EE_Attendee) {
773
-            $attendee_name = $attendee->full_name($apply_html_entities);
774
-        } else {
775
-            $attendee_name = esc_html__('Unknown', 'event_espresso');
776
-        }
777
-        return $attendee_name;
778
-    }
779
-
780
-
781
-    /**
782
-     *        get Event ID
783
-     */
784
-    public function event_ID()
785
-    {
786
-        return $this->get('EVT_ID');
787
-    }
788
-
789
-
790
-    /**
791
-     *        get Event ID
792
-     */
793
-    public function event_name()
794
-    {
795
-        $event = $this->event_obj();
796
-        if ($event) {
797
-            return $event->name();
798
-        } else {
799
-            return null;
800
-        }
801
-    }
802
-
803
-
804
-    /**
805
-     * Fetches the event this registration is for
806
-     *
807
-     * @return EE_Event
808
-     * @throws EE_Error
809
-     */
810
-    public function event_obj()
811
-    {
812
-        return $this->get_first_related('Event');
813
-    }
814
-
815
-
816
-    /**
817
-     *        get Attendee ID
818
-     */
819
-    public function attendee_ID()
820
-    {
821
-        return $this->get('ATT_ID');
822
-    }
823
-
824
-
825
-    /**
826
-     *        get PHP Session ID
827
-     */
828
-    public function session_ID()
829
-    {
830
-        return $this->get('REG_session');
831
-    }
832
-
833
-
834
-    /**
835
-     * Gets the string which represents the URL trigger for the receipt template in the message template system.
836
-     *
837
-     * @param string $messenger 'pdf' or 'html'.  Default 'html'.
838
-     * @return string
839
-     */
840
-    public function receipt_url($messenger = 'html')
841
-    {
842
-
843
-        /**
844
-         * The below will be deprecated one version after this.  We check first if there is a custom receipt template
845
-         * already in use on old system.  If there is then we just return the standard url for it.
846
-         *
847
-         * @since 4.5.0
848
-         */
849
-        $template_relative_path = 'modules/gateways/Invoice/lib/templates/receipt_body.template.php';
850
-        $has_custom = EEH_Template::locate_template(
851
-            $template_relative_path,
852
-            array(),
853
-            true,
854
-            true,
855
-            true
856
-        );
857
-
858
-        if ($has_custom) {
859
-            return add_query_arg(array('receipt' => 'true'), $this->invoice_url('launch'));
860
-        }
861
-        return apply_filters('FHEE__EE_Registration__receipt_url__receipt_url', '', $this, $messenger, 'receipt');
862
-    }
863
-
864
-
865
-    /**
866
-     * Gets the string which represents the URL trigger for the invoice template in the message template system.
867
-     *
868
-     * @param string $messenger 'pdf' or 'html'.  Default 'html'.
869
-     * @return string
870
-     * @throws EE_Error
871
-     */
872
-    public function invoice_url($messenger = 'html')
873
-    {
874
-        /**
875
-         * The below will be deprecated one version after this.  We check first if there is a custom invoice template
876
-         * already in use on old system.  If there is then we just return the standard url for it.
877
-         *
878
-         * @since 4.5.0
879
-         */
880
-        $template_relative_path = 'modules/gateways/Invoice/lib/templates/invoice_body.template.php';
881
-        $has_custom = EEH_Template::locate_template(
882
-            $template_relative_path,
883
-            array(),
884
-            true,
885
-            true,
886
-            true
887
-        );
888
-
889
-        if ($has_custom) {
890
-            if ($messenger == 'html') {
891
-                return $this->invoice_url('launch');
892
-            }
893
-            $route = $messenger == 'download' || $messenger == 'pdf' ? 'download_invoice' : 'launch_invoice';
894
-
895
-            $query_args = array('ee' => $route, 'id' => $this->reg_url_link());
896
-            if ($messenger == 'html') {
897
-                $query_args['html'] = true;
898
-            }
899
-            return add_query_arg($query_args, get_permalink(EE_Registry::instance()->CFG->core->thank_you_page_id));
900
-        }
901
-        return apply_filters('FHEE__EE_Registration__invoice_url__invoice_url', '', $this, $messenger, 'invoice');
902
-    }
903
-
904
-
905
-    /**
906
-     * get Registration URL Link
907
-     *
908
-     * @access public
909
-     * @return string
910
-     * @throws EE_Error
911
-     */
912
-    public function reg_url_link()
913
-    {
914
-        return (string) $this->get('REG_url_link');
915
-    }
916
-
917
-
918
-    /**
919
-     * Echoes out invoice_url()
920
-     *
921
-     * @param string $type 'download','launch', or 'html' (default is 'launch')
922
-     * @return void
923
-     * @throws EE_Error
924
-     */
925
-    public function e_invoice_url($type = 'launch')
926
-    {
927
-        echo esc_url_raw($this->invoice_url($type));
928
-    }
929
-
930
-
931
-    /**
932
-     * Echoes out payment_overview_url
933
-     */
934
-    public function e_payment_overview_url()
935
-    {
936
-        echo esc_url_raw($this->payment_overview_url());
937
-    }
938
-
939
-
940
-    /**
941
-     * Gets the URL for the checkout payment options reg step
942
-     * with this registration's REG_url_link added as a query parameter
943
-     *
944
-     * @param bool $clear_session Set to true when you want to clear the session on revisiting the
945
-     *                            payment overview url.
946
-     * @return string
947
-     * @throws InvalidInterfaceException
948
-     * @throws InvalidDataTypeException
949
-     * @throws EE_Error
950
-     * @throws InvalidArgumentException
951
-     */
952
-    public function payment_overview_url($clear_session = false)
953
-    {
954
-        return add_query_arg(
955
-            (array) apply_filters(
956
-                'FHEE__EE_Registration__payment_overview_url__query_args',
957
-                array(
958
-                    'e_reg_url_link' => $this->reg_url_link(),
959
-                    'step'           => 'payment_options',
960
-                    'revisit'        => true,
961
-                    'clear_session'  => (bool) $clear_session,
962
-                ),
963
-                $this
964
-            ),
965
-            EE_Registry::instance()->CFG->core->reg_page_url()
966
-        );
967
-    }
968
-
969
-
970
-    /**
971
-     * Gets the URL for the checkout attendee information reg step
972
-     * with this registration's REG_url_link added as a query parameter
973
-     *
974
-     * @return string
975
-     * @throws InvalidInterfaceException
976
-     * @throws InvalidDataTypeException
977
-     * @throws EE_Error
978
-     * @throws InvalidArgumentException
979
-     */
980
-    public function edit_attendee_information_url()
981
-    {
982
-        return add_query_arg(
983
-            (array) apply_filters(
984
-                'FHEE__EE_Registration__edit_attendee_information_url__query_args',
985
-                array(
986
-                    'e_reg_url_link' => $this->reg_url_link(),
987
-                    'step'           => 'attendee_information',
988
-                    'revisit'        => true,
989
-                ),
990
-                $this
991
-            ),
992
-            EE_Registry::instance()->CFG->core->reg_page_url()
993
-        );
994
-    }
995
-
996
-
997
-    /**
998
-     * Simply generates and returns the appropriate admin_url link to edit this registration
999
-     *
1000
-     * @return string
1001
-     * @throws EE_Error
1002
-     */
1003
-    public function get_admin_edit_url()
1004
-    {
1005
-        return EEH_URL::add_query_args_and_nonce(
1006
-            array(
1007
-                'page'    => 'espresso_registrations',
1008
-                'action'  => 'view_registration',
1009
-                '_REG_ID' => $this->ID(),
1010
-            ),
1011
-            admin_url('admin.php')
1012
-        );
1013
-    }
1014
-
1015
-
1016
-    /**
1017
-     *    is_primary_registrant?
1018
-     */
1019
-    public function is_primary_registrant()
1020
-    {
1021
-        return $this->get('REG_count') === 1 ? true : false;
1022
-    }
1023
-
1024
-
1025
-    /**
1026
-     * This returns the primary registration object for this registration group (which may be this object).
1027
-     *
1028
-     * @return EE_Registration
1029
-     * @throws EE_Error
1030
-     */
1031
-    public function get_primary_registration()
1032
-    {
1033
-        if ($this->is_primary_registrant()) {
1034
-            return $this;
1035
-        }
1036
-
1037
-        // k reg_count !== 1 so let's get the EE_Registration object matching this txn_id and reg_count == 1
1038
-        /** @var EE_Registration $primary_registrant */
1039
-        $primary_registrant = EEM_Registration::instance()->get_one(
1040
-            array(
1041
-                array(
1042
-                    'TXN_ID'    => $this->transaction_ID(),
1043
-                    'REG_count' => 1,
1044
-                ),
1045
-            )
1046
-        );
1047
-        return $primary_registrant;
1048
-    }
1049
-
1050
-
1051
-    /**
1052
-     *        get  Attendee Number
1053
-     *
1054
-     * @access        public
1055
-     */
1056
-    public function count()
1057
-    {
1058
-        return $this->get('REG_count');
1059
-    }
1060
-
1061
-
1062
-    /**
1063
-     *        get Group Size
1064
-     */
1065
-    public function group_size()
1066
-    {
1067
-        return $this->get('REG_group_size');
1068
-    }
1069
-
1070
-
1071
-    /**
1072
-     *        get Registration Date
1073
-     */
1074
-    public function date()
1075
-    {
1076
-        return $this->get('REG_date');
1077
-    }
1078
-
1079
-
1080
-    /**
1081
-     * gets a pretty date
1082
-     *
1083
-     * @param string $date_format
1084
-     * @param string $time_format
1085
-     * @return string
1086
-     * @throws EE_Error
1087
-     */
1088
-    public function pretty_date($date_format = null, $time_format = null)
1089
-    {
1090
-        return $this->get_datetime('REG_date', $date_format, $time_format);
1091
-    }
1092
-
1093
-
1094
-    /**
1095
-     * final_price
1096
-     * the registration's share of the transaction total, so that the
1097
-     * sum of all the transaction's REG_final_prices equal the transaction's total
1098
-     *
1099
-     * @return float
1100
-     * @throws EE_Error
1101
-     */
1102
-    public function final_price()
1103
-    {
1104
-        return $this->get('REG_final_price');
1105
-    }
1106
-
1107
-
1108
-    /**
1109
-     * pretty_final_price
1110
-     *  final price as formatted string, with correct decimal places and currency symbol
1111
-     *
1112
-     * @return string
1113
-     * @throws EE_Error
1114
-     */
1115
-    public function pretty_final_price()
1116
-    {
1117
-        return $this->get_pretty('REG_final_price');
1118
-    }
1119
-
1120
-
1121
-    /**
1122
-     * get paid (yeah)
1123
-     *
1124
-     * @return float
1125
-     * @throws EE_Error
1126
-     */
1127
-    public function paid()
1128
-    {
1129
-        return $this->get('REG_paid');
1130
-    }
1131
-
1132
-
1133
-    /**
1134
-     * pretty_paid
1135
-     *
1136
-     * @return float
1137
-     * @throws EE_Error
1138
-     */
1139
-    public function pretty_paid()
1140
-    {
1141
-        return $this->get_pretty('REG_paid');
1142
-    }
1143
-
1144
-
1145
-    /**
1146
-     * owes_monies_and_can_pay
1147
-     * whether or not this registration has monies owing and it's' status allows payment
1148
-     *
1149
-     * @param array $requires_payment
1150
-     * @return bool
1151
-     * @throws EE_Error
1152
-     */
1153
-    public function owes_monies_and_can_pay($requires_payment = array())
1154
-    {
1155
-        // these reg statuses require payment (if event is not free)
1156
-        $requires_payment = ! empty($requires_payment)
1157
-            ? $requires_payment
1158
-            : EEM_Registration::reg_statuses_that_allow_payment();
1159
-        if (
1160
-            in_array($this->status_ID(), $requires_payment) &&
1161
-            $this->final_price() != 0 &&
1162
-            $this->final_price() != $this->paid()
1163
-        ) {
1164
-            return true;
1165
-        } else {
1166
-            return false;
1167
-        }
1168
-    }
1169
-
1170
-
1171
-    /**
1172
-     * Prints out the return value of $this->pretty_status()
1173
-     *
1174
-     * @param bool $show_icons
1175
-     * @return void
1176
-     * @throws EE_Error
1177
-     */
1178
-    public function e_pretty_status($show_icons = false)
1179
-    {
1180
-        echo $this->pretty_status($show_icons); // already escaped
1181
-    }
1182
-
1183
-
1184
-    /**
1185
-     * Returns a nice version of the status for displaying to customers
1186
-     *
1187
-     * @param bool $show_icons
1188
-     * @return string
1189
-     * @throws EE_Error
1190
-     */
1191
-    public function pretty_status($show_icons = false)
1192
-    {
1193
-        $status = EEM_Status::instance()->localized_status(
1194
-            array($this->status_ID() => esc_html__('unknown', 'event_espresso')),
1195
-            false,
1196
-            'sentence'
1197
-        );
1198
-        $icon = '';
1199
-        switch ($this->status_ID()) {
1200
-            case EEM_Registration::status_id_approved:
1201
-                $icon = $show_icons
1202
-                    ? '<span class="dashicons dashicons-star-filled ee-icon-size-16 green-text"></span>'
1203
-                    : '';
1204
-                break;
1205
-            case EEM_Registration::status_id_pending_payment:
1206
-                $icon = $show_icons
1207
-                    ? '<span class="dashicons dashicons-star-half ee-icon-size-16 orange-text"></span>'
1208
-                    : '';
1209
-                break;
1210
-            case EEM_Registration::status_id_not_approved:
1211
-                $icon = $show_icons
1212
-                    ? '<span class="dashicons dashicons-marker ee-icon-size-16 orange-text"></span>'
1213
-                    : '';
1214
-                break;
1215
-            case EEM_Registration::status_id_cancelled:
1216
-                $icon = $show_icons
1217
-                    ? '<span class="dashicons dashicons-no ee-icon-size-16 lt-grey-text"></span>'
1218
-                    : '';
1219
-                break;
1220
-            case EEM_Registration::status_id_incomplete:
1221
-                $icon = $show_icons
1222
-                    ? '<span class="dashicons dashicons-no ee-icon-size-16 lt-orange-text"></span>'
1223
-                    : '';
1224
-                break;
1225
-            case EEM_Registration::status_id_declined:
1226
-                $icon = $show_icons
1227
-                    ? '<span class="dashicons dashicons-no ee-icon-size-16 red-text"></span>'
1228
-                    : '';
1229
-                break;
1230
-            case EEM_Registration::status_id_wait_list:
1231
-                $icon = $show_icons
1232
-                    ? '<span class="dashicons dashicons-clipboard ee-icon-size-16 purple-text"></span>'
1233
-                    : '';
1234
-                break;
1235
-        }
1236
-        return $icon . $status[ $this->status_ID() ];
1237
-    }
1238
-
1239
-
1240
-    /**
1241
-     *        get Attendee Is Going
1242
-     */
1243
-    public function att_is_going()
1244
-    {
1245
-        return $this->get('REG_att_is_going');
1246
-    }
1247
-
1248
-
1249
-    /**
1250
-     * Gets related answers
1251
-     *
1252
-     * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1253
-     * @return EE_Answer[]
1254
-     * @throws EE_Error
1255
-     */
1256
-    public function answers($query_params = null)
1257
-    {
1258
-        return $this->get_many_related('Answer', $query_params);
1259
-    }
1260
-
1261
-
1262
-    /**
1263
-     * Gets the registration's answer value to the specified question
1264
-     * (either the question's ID or a question object)
1265
-     *
1266
-     * @param EE_Question|int $question
1267
-     * @param bool            $pretty_value
1268
-     * @return array|string if pretty_value= true, the result will always be a string
1269
-     * (because the answer might be an array of answer values, so passing pretty_value=true
1270
-     * will convert it into some kind of string)
1271
-     * @throws EE_Error
1272
-     */
1273
-    public function answer_value_to_question($question, $pretty_value = true)
1274
-    {
1275
-        $question_id = EEM_Question::instance()->ensure_is_ID($question);
1276
-        return EEM_Answer::instance()->get_answer_value_to_question($this, $question_id, $pretty_value);
1277
-    }
1278
-
1279
-
1280
-    /**
1281
-     * question_groups
1282
-     * returns an array of EE_Question_Group objects for this registration
1283
-     *
1284
-     * @return EE_Question_Group[]
1285
-     * @throws EE_Error
1286
-     * @throws InvalidArgumentException
1287
-     * @throws InvalidDataTypeException
1288
-     * @throws InvalidInterfaceException
1289
-     * @throws ReflectionException
1290
-     */
1291
-    public function question_groups()
1292
-    {
1293
-        return EEM_Event::instance()->get_question_groups_for_event($this->event_ID(), $this);
1294
-    }
1295
-
1296
-
1297
-    /**
1298
-     * count_question_groups
1299
-     * returns a count of the number of EE_Question_Group objects for this registration
1300
-     *
1301
-     * @return int
1302
-     * @throws EE_Error
1303
-     * @throws EntityNotFoundException
1304
-     * @throws InvalidArgumentException
1305
-     * @throws InvalidDataTypeException
1306
-     * @throws InvalidInterfaceException
1307
-     * @throws ReflectionException
1308
-     */
1309
-    public function count_question_groups()
1310
-    {
1311
-        return EEM_Event::instance()->count_related(
1312
-            $this->event_ID(),
1313
-            'Question_Group',
1314
-            [
1315
-                [
1316
-                    'Event_Question_Group.'
1317
-                    . EEM_Event_Question_Group::instance()->fieldNameForContext($this->is_primary_registrant()) => true,
1318
-                ]
1319
-            ]
1320
-        );
1321
-    }
1322
-
1323
-
1324
-    /**
1325
-     * Returns the registration date in the 'standard' string format
1326
-     * (function may be improved in the future to allow for different formats and timezones)
1327
-     *
1328
-     * @return string
1329
-     * @throws EE_Error
1330
-     */
1331
-    public function reg_date()
1332
-    {
1333
-        return $this->get_datetime('REG_date');
1334
-    }
1335
-
1336
-
1337
-    /**
1338
-     * Gets the datetime-ticket for this registration (ie, it can be used to isolate
1339
-     * the ticket this registration purchased, or the datetime they have registered
1340
-     * to attend)
1341
-     *
1342
-     * @return EE_Datetime_Ticket
1343
-     * @throws EE_Error
1344
-     */
1345
-    public function datetime_ticket()
1346
-    {
1347
-        return $this->get_first_related('Datetime_Ticket');
1348
-    }
1349
-
1350
-
1351
-    /**
1352
-     * Sets the registration's datetime_ticket.
1353
-     *
1354
-     * @param EE_Datetime_Ticket $datetime_ticket
1355
-     * @return EE_Datetime_Ticket
1356
-     * @throws EE_Error
1357
-     */
1358
-    public function set_datetime_ticket($datetime_ticket)
1359
-    {
1360
-        return $this->_add_relation_to($datetime_ticket, 'Datetime_Ticket');
1361
-    }
1362
-
1363
-    /**
1364
-     * Gets deleted
1365
-     *
1366
-     * @return bool
1367
-     * @throws EE_Error
1368
-     */
1369
-    public function deleted()
1370
-    {
1371
-        return $this->get('REG_deleted');
1372
-    }
1373
-
1374
-    /**
1375
-     * Sets deleted
1376
-     *
1377
-     * @param boolean $deleted
1378
-     * @return bool
1379
-     * @throws EE_Error
1380
-     * @throws RuntimeException
1381
-     */
1382
-    public function set_deleted($deleted)
1383
-    {
1384
-        if ($deleted) {
1385
-            $this->delete();
1386
-        } else {
1387
-            $this->restore();
1388
-        }
1389
-    }
1390
-
1391
-
1392
-    /**
1393
-     * Get the status object of this object
1394
-     *
1395
-     * @return EE_Status
1396
-     * @throws EE_Error
1397
-     */
1398
-    public function status_obj()
1399
-    {
1400
-        return $this->get_first_related('Status');
1401
-    }
1402
-
1403
-
1404
-    /**
1405
-     * Returns the number of times this registration has checked into any of the datetimes
1406
-     * its available for
1407
-     *
1408
-     * @return int
1409
-     * @throws EE_Error
1410
-     */
1411
-    public function count_checkins()
1412
-    {
1413
-        return $this->get_model()->count_related($this, 'Checkin');
1414
-    }
1415
-
1416
-
1417
-    /**
1418
-     * Returns the number of current Check-ins this registration is checked into for any of the datetimes the
1419
-     * registration is for.  Note, this is ONLY checked in (does not include checkedout)
1420
-     *
1421
-     * @return int
1422
-     * @throws EE_Error
1423
-     */
1424
-    public function count_checkins_not_checkedout()
1425
-    {
1426
-        return $this->get_model()->count_related($this, 'Checkin', array(array('CHK_in' => 1)));
1427
-    }
1428
-
1429
-
1430
-    /**
1431
-     * The purpose of this method is simply to check whether this registration can checkin to the given datetime.
1432
-     *
1433
-     * @param int | EE_Datetime $DTT_OR_ID      The datetime the registration is being checked against
1434
-     * @param bool              $check_approved This is used to indicate whether the caller wants can_checkin to also
1435
-     *                                          consider registration status as well as datetime access.
1436
-     * @return bool
1437
-     * @throws EE_Error
1438
-     */
1439
-    public function can_checkin($DTT_OR_ID, $check_approved = true)
1440
-    {
1441
-        $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID);
1442
-
1443
-        // first check registration status
1444
-        if (($check_approved && ! $this->is_approved()) || ! $DTT_ID) {
1445
-            return false;
1446
-        }
1447
-        // is there a datetime ticket that matches this dtt_ID?
1448
-        if (
1449
-            ! (EEM_Datetime_Ticket::instance()->exists(
1450
-                array(
1451
-                array(
1452
-                    'TKT_ID' => $this->get('TKT_ID'),
1453
-                    'DTT_ID' => $DTT_ID,
1454
-                ),
1455
-                )
1456
-            ))
1457
-        ) {
1458
-            return false;
1459
-        }
1460
-
1461
-        // final check is against TKT_uses
1462
-        return $this->verify_can_checkin_against_TKT_uses($DTT_ID);
1463
-    }
1464
-
1465
-
1466
-    /**
1467
-     * This method verifies whether the user can checkin for the given datetime considering the max uses value set on
1468
-     * the ticket. To do this,  a query is done to get the count of the datetime records already checked into.  If the
1469
-     * datetime given does not have a check-in record and checking in for that datetime will exceed the allowed uses,
1470
-     * then return false.  Otherwise return true.
1471
-     *
1472
-     * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against
1473
-     * @return bool true means can checkin.  false means cannot checkin.
1474
-     * @throws EE_Error
1475
-     */
1476
-    public function verify_can_checkin_against_TKT_uses($DTT_OR_ID)
1477
-    {
1478
-        $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID);
1479
-
1480
-        if (! $DTT_ID) {
1481
-            return false;
1482
-        }
1483
-
1484
-        $max_uses = $this->ticket() instanceof EE_Ticket ? $this->ticket()->uses() : EE_INF;
1485
-
1486
-        // if max uses is not set or equals infinity then return true cause its not a factor for whether user can
1487
-        // check-in or not.
1488
-        if (! $max_uses || $max_uses === EE_INF) {
1489
-            return true;
1490
-        }
1491
-
1492
-        // does this datetime have a checkin record?  If so, then the dtt count has already been verified so we can just
1493
-        // go ahead and toggle.
1494
-        if (EEM_Checkin::instance()->exists(array(array('REG_ID' => $this->ID(), 'DTT_ID' => $DTT_ID)))) {
1495
-            return true;
1496
-        }
1497
-
1498
-        // made it here so the last check is whether the number of checkins per unique datetime on this registration
1499
-        // disallows further check-ins.
1500
-        $count_unique_dtt_checkins = EEM_Checkin::instance()->count(
1501
-            array(
1502
-                array(
1503
-                    'REG_ID' => $this->ID(),
1504
-                    'CHK_in' => true,
1505
-                ),
1506
-            ),
1507
-            'DTT_ID',
1508
-            true
1509
-        );
1510
-        // checkins have already reached their max number of uses
1511
-        // so registrant can NOT checkin
1512
-        if ($count_unique_dtt_checkins >= $max_uses) {
1513
-            EE_Error::add_error(
1514
-                esc_html__(
1515
-                    'Check-in denied because number of datetime uses for the ticket has been reached or exceeded.',
1516
-                    'event_espresso'
1517
-                ),
1518
-                __FILE__,
1519
-                __FUNCTION__,
1520
-                __LINE__
1521
-            );
1522
-            return false;
1523
-        }
1524
-        return true;
1525
-    }
1526
-
1527
-
1528
-    /**
1529
-     * toggle Check-in status for this registration
1530
-     * Check-ins are toggled in the following order:
1531
-     * never checked in -> checked in
1532
-     * checked in -> checked out
1533
-     * checked out -> checked in
1534
-     *
1535
-     * @param  int $DTT_ID  include specific datetime to toggle Check-in for.
1536
-     *                      If not included or null, then it is assumed latest datetime is being toggled.
1537
-     * @param bool $verify  If true then can_checkin() is used to verify whether the person
1538
-     *                      can be checked in or not.  Otherwise this forces change in checkin status.
1539
-     * @return bool|int     the chk_in status toggled to OR false if nothing got changed.
1540
-     * @throws EE_Error
1541
-     */
1542
-    public function toggle_checkin_status($DTT_ID = null, $verify = false)
1543
-    {
1544
-        if (empty($DTT_ID)) {
1545
-            $datetime = $this->get_latest_related_datetime();
1546
-            $DTT_ID = $datetime instanceof EE_Datetime ? $datetime->ID() : 0;
1547
-            // verify the registration can checkin for the given DTT_ID
1548
-        } elseif (! $this->can_checkin($DTT_ID, $verify)) {
1549
-            EE_Error::add_error(
1550
-                sprintf(
1551
-                    esc_html__(
1552
-                        'The given registration (ID:%1$d) can not be checked in to the given DTT_ID (%2$d), because the registration does not have access',
1553
-                        'event_espresso'
1554
-                    ),
1555
-                    $this->ID(),
1556
-                    $DTT_ID
1557
-                ),
1558
-                __FILE__,
1559
-                __FUNCTION__,
1560
-                __LINE__
1561
-            );
1562
-            return false;
1563
-        }
1564
-        $status_paths = array(
1565
-            EE_Checkin::status_checked_never => EE_Checkin::status_checked_in,
1566
-            EE_Checkin::status_checked_in    => EE_Checkin::status_checked_out,
1567
-            EE_Checkin::status_checked_out   => EE_Checkin::status_checked_in,
1568
-        );
1569
-        // start by getting the current status so we know what status we'll be changing to.
1570
-        $cur_status = $this->check_in_status_for_datetime($DTT_ID);
1571
-        $status_to = $status_paths[ $cur_status ];
1572
-        // database only records true for checked IN or false for checked OUT
1573
-        // no record ( null ) means checked in NEVER, but we obviously don't save that
1574
-        $new_status = $status_to === EE_Checkin::status_checked_in ? true : false;
1575
-        // add relation - note Check-ins are always creating new rows
1576
-        // because we are keeping track of Check-ins over time.
1577
-        // Eventually we'll probably want to show a list table
1578
-        // for the individual Check-ins so that they can be managed.
1579
-        $checkin = EE_Checkin::new_instance(
1580
-            array(
1581
-                'REG_ID' => $this->ID(),
1582
-                'DTT_ID' => $DTT_ID,
1583
-                'CHK_in' => $new_status,
1584
-            )
1585
-        );
1586
-        // if the record could not be saved then return false
1587
-        if ($checkin->save() === 0) {
1588
-            if (WP_DEBUG) {
1589
-                global $wpdb;
1590
-                $error = sprintf(
1591
-                    esc_html__(
1592
-                        'Registration check in update failed because of the following database error: %1$s%2$s',
1593
-                        'event_espresso'
1594
-                    ),
1595
-                    '<br />',
1596
-                    $wpdb->last_error
1597
-                );
1598
-            } else {
1599
-                $error = esc_html__(
1600
-                    'Registration check in update failed because of an unknown database error',
1601
-                    'event_espresso'
1602
-                );
1603
-            }
1604
-            EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
1605
-            return false;
1606
-        }
1607
-        // Fire a checked_in and checkout_out action.
1608
-        $checked_status = $status_to === EE_Checkin::status_checked_in ? 'checked_in' : 'checked_out';
1609
-        do_action("AHEE__EE_Registration__toggle_checkin_status__{$checked_status}", $this, $DTT_ID);
1610
-        return $status_to;
1611
-    }
1612
-
1613
-
1614
-    /**
1615
-     * Returns the latest datetime related to this registration (via the ticket attached to the registration).
1616
-     * "Latest" is defined by the `DTT_EVT_start` column.
1617
-     *
1618
-     * @return EE_Datetime|null
1619
-     * @throws EE_Error
1620
-     */
1621
-    public function get_latest_related_datetime()
1622
-    {
1623
-        return EEM_Datetime::instance()->get_one(
1624
-            array(
1625
-                array(
1626
-                    'Ticket.Registration.REG_ID' => $this->ID(),
1627
-                ),
1628
-                'order_by' => array('DTT_EVT_start' => 'DESC'),
1629
-            )
1630
-        );
1631
-    }
1632
-
1633
-
1634
-    /**
1635
-     * Returns the earliest datetime related to this registration (via the ticket attached to the registration).
1636
-     * "Earliest" is defined by the `DTT_EVT_start` column.
1637
-     *
1638
-     * @throws EE_Error
1639
-     */
1640
-    public function get_earliest_related_datetime()
1641
-    {
1642
-        return EEM_Datetime::instance()->get_one(
1643
-            array(
1644
-                array(
1645
-                    'Ticket.Registration.REG_ID' => $this->ID(),
1646
-                ),
1647
-                'order_by' => array('DTT_EVT_start' => 'ASC'),
1648
-            )
1649
-        );
1650
-    }
1651
-
1652
-
1653
-    /**
1654
-     * This method simply returns the check-in status for this registration and the given datetime.
1655
-     * If neither the datetime nor the checkin values are provided as arguments,
1656
-     * then this will return the LATEST check-in status for the registration across all datetimes it belongs to.
1657
-     *
1658
-     * @param int|null        $DTT_ID  The ID of the datetime we're checking against
1659
-     *                                 (if empty we'll get the primary datetime for
1660
-     *                                 this registration (via event) and use it's ID);
1661
-     * @param EE_Checkin|null $checkin If present, we use the given checkin object rather than the dtt_id.
1662
-     * @return int                     Integer representing Check-in status.
1663
-     * @throws EE_Error
1664
-     * @throws ReflectionException
1665
-     */
1666
-    public function check_in_status_for_datetime(?int $DTT_ID = 0, ?EE_Checkin $checkin = null): int
1667
-    {
1668
-        if ($checkin instanceof EE_Checkin) {
1669
-            return $checkin->status();
1670
-        }
1671
-        // can't query checkin for a specific date if no ID was supplied
1672
-        if (empty($DTT_ID)) {
1673
-            return EE_Checkin::status_invalid;
1674
-        }
1675
-
1676
-        $checkin = $this->get_first_related(
1677
-            'Checkin',
1678
-            [
1679
-                ['DTT_ID' => $DTT_ID],
1680
-                'order_by' => ['CHK_timestamp' => 'DESC'],
1681
-            ]
1682
-        );
1683
-        return $checkin instanceof EE_Checkin ? $checkin->status():  EE_Checkin::status_checked_never;
1684
-    }
1685
-
1686
-
1687
-    /**
1688
-     * This method returns a localized message for the toggled Check-in message.
1689
-     *
1690
-     * @param int|null $DTT_ID include specific datetime to get the correct Check-in message.  If not included or null,
1691
-     *                         then it is assumed Check-in for primary datetime was toggled.
1692
-     * @param bool     $error  This just flags that you want an error message returned. This is put in so that the error
1693
-     *                         message can be customized with the attendee name.
1694
-     * @return string internationalized message
1695
-     * @throws EE_Error
1696
-     * @throws ReflectionException
1697
-     */
1698
-    public function get_checkin_msg(?int $DTT_ID, bool $error = false): string
1699
-    {
1700
-        // let's get the attendee first so we can include the name of the attendee
1701
-        $attendee = $this->get_first_related('Attendee');
1702
-        if ($attendee instanceof EE_Attendee) {
1703
-            if ($error) {
1704
-                return sprintf(
1705
-                    esc_html__("%s's check-in status was not changed.", "event_espresso"),
1706
-                    $attendee->full_name()
1707
-                );
1708
-            }
1709
-            $cur_status = $this->check_in_status_for_datetime($DTT_ID);
1710
-            // what is the status message going to be?
1711
-            switch ($cur_status) {
1712
-                case EE_Checkin::status_checked_never:
1713
-                    return sprintf(
1714
-                        esc_html__("%s has been removed from Check-in records", "event_espresso"),
1715
-                        $attendee->full_name()
1716
-                    );
1717
-                case EE_Checkin::status_checked_in:
1718
-                    return sprintf(esc_html__('%s has been checked in', 'event_espresso'), $attendee->full_name());
1719
-                case EE_Checkin::status_checked_out:
1720
-                    return sprintf(esc_html__('%s has been checked out', 'event_espresso'), $attendee->full_name());
1721
-            }
1722
-        }
1723
-        return esc_html__("The check-in status could not be determined.", "event_espresso");
1724
-    }
1725
-
1726
-
1727
-    /**
1728
-     * Returns the related EE_Transaction to this registration
1729
-     *
1730
-     * @return EE_Transaction
1731
-     * @throws EE_Error
1732
-     * @throws EntityNotFoundException
1733
-     * @throws ReflectionException
1734
-     */
1735
-    public function transaction(): EE_Transaction
1736
-    {
1737
-        $transaction = $this->get_first_related('Transaction');
1738
-        if (! $transaction instanceof \EE_Transaction) {
1739
-            throw new EntityNotFoundException('Transaction ID', $this->transaction_ID());
1740
-        }
1741
-        return $transaction;
1742
-    }
1743
-
1744
-
1745
-    /**
1746
-     *        get Registration Code
1747
-     */
1748
-    public function reg_code()
1749
-    {
1750
-        return $this->get('REG_code');
1751
-    }
1752
-
1753
-
1754
-    /**
1755
-     *        get Transaction ID
1756
-     */
1757
-    public function transaction_ID()
1758
-    {
1759
-        return $this->get('TXN_ID');
1760
-    }
1761
-
1762
-
1763
-    /**
1764
-     * @return int
1765
-     * @throws EE_Error
1766
-     */
1767
-    public function ticket_ID()
1768
-    {
1769
-        return $this->get('TKT_ID');
1770
-    }
1771
-
1772
-
1773
-    /**
1774
-     *        Set Registration Code
1775
-     *
1776
-     * @access    public
1777
-     * @param    string  $REG_code Registration Code
1778
-     * @param    boolean $use_default
1779
-     * @throws EE_Error
1780
-     */
1781
-    public function set_reg_code($REG_code, $use_default = false)
1782
-    {
1783
-        if (empty($REG_code)) {
1784
-            EE_Error::add_error(
1785
-                esc_html__('REG_code can not be empty.', 'event_espresso'),
1786
-                __FILE__,
1787
-                __FUNCTION__,
1788
-                __LINE__
1789
-            );
1790
-            return;
1791
-        }
1792
-        if (! $this->reg_code()) {
1793
-            parent::set('REG_code', $REG_code, $use_default);
1794
-        } else {
1795
-            EE_Error::doing_it_wrong(
1796
-                __CLASS__ . '::' . __FUNCTION__,
1797
-                esc_html__('Can not change a registration REG_code once it has been set.', 'event_espresso'),
1798
-                '4.6.0'
1799
-            );
1800
-        }
1801
-    }
1802
-
1803
-
1804
-    /**
1805
-     * Returns all other registrations in the same group as this registrant who have the same ticket option.
1806
-     * Note, if you want to just get all registrations in the same transaction (group), use:
1807
-     *    $registration->transaction()->registrations();
1808
-     *
1809
-     * @since 4.5.0
1810
-     * @return EE_Registration[] or empty array if this isn't a group registration.
1811
-     * @throws EE_Error
1812
-     */
1813
-    public function get_all_other_registrations_in_group()
1814
-    {
1815
-        if ($this->group_size() < 2) {
1816
-            return array();
1817
-        }
1818
-
1819
-        $query[0] = array(
1820
-            'TXN_ID' => $this->transaction_ID(),
1821
-            'REG_ID' => array('!=', $this->ID()),
1822
-            'TKT_ID' => $this->ticket_ID(),
1823
-        );
1824
-        /** @var EE_Registration[] $registrations */
1825
-        $registrations = $this->get_model()->get_all($query);
1826
-        return $registrations;
1827
-    }
1828
-
1829
-    /**
1830
-     * Return the link to the admin details for the object.
1831
-     *
1832
-     * @return string
1833
-     * @throws EE_Error
1834
-     */
1835
-    public function get_admin_details_link()
1836
-    {
1837
-        EE_Registry::instance()->load_helper('URL');
1838
-        return EEH_URL::add_query_args_and_nonce(
1839
-            array(
1840
-                'page'    => 'espresso_registrations',
1841
-                'action'  => 'view_registration',
1842
-                '_REG_ID' => $this->ID(),
1843
-            ),
1844
-            admin_url('admin.php')
1845
-        );
1846
-    }
1847
-
1848
-    /**
1849
-     * Returns the link to the editor for the object.  Sometimes this is the same as the details.
1850
-     *
1851
-     * @return string
1852
-     * @throws EE_Error
1853
-     */
1854
-    public function get_admin_edit_link()
1855
-    {
1856
-        return $this->get_admin_details_link();
1857
-    }
1858
-
1859
-    /**
1860
-     * Returns the link to a settings page for the object.
1861
-     *
1862
-     * @return string
1863
-     * @throws EE_Error
1864
-     */
1865
-    public function get_admin_settings_link()
1866
-    {
1867
-        return $this->get_admin_details_link();
1868
-    }
1869
-
1870
-    /**
1871
-     * Returns the link to the "overview" for the object (typically the "list table" view).
1872
-     *
1873
-     * @return string
1874
-     */
1875
-    public function get_admin_overview_link()
1876
-    {
1877
-        EE_Registry::instance()->load_helper('URL');
1878
-        return EEH_URL::add_query_args_and_nonce(
1879
-            array(
1880
-                'page' => 'espresso_registrations',
1881
-            ),
1882
-            admin_url('admin.php')
1883
-        );
1884
-    }
1885
-
1886
-
1887
-    /**
1888
-     * @param array $query_params
1889
-     *
1890
-     * @return \EE_Registration[]
1891
-     * @throws EE_Error
1892
-     */
1893
-    public function payments($query_params = array())
1894
-    {
1895
-        return $this->get_many_related('Payment', $query_params);
1896
-    }
1897
-
1898
-
1899
-    /**
1900
-     * @param array $query_params
1901
-     *
1902
-     * @return \EE_Registration_Payment[]
1903
-     * @throws EE_Error
1904
-     */
1905
-    public function registration_payments($query_params = array())
1906
-    {
1907
-        return $this->get_many_related('Registration_Payment', $query_params);
1908
-    }
1909
-
1910
-
1911
-    /**
1912
-     * This grabs the payment method corresponding to the last payment made for the amount owing on the registration.
1913
-     * Note: if there are no payments on the registration there will be no payment method returned.
1914
-     *
1915
-     * @return EE_Payment_Method|null
1916
-     */
1917
-    public function payment_method()
1918
-    {
1919
-        return EEM_Payment_Method::instance()->get_last_used_for_registration($this);
1920
-    }
1921
-
1922
-
1923
-    /**
1924
-     * @return \EE_Line_Item
1925
-     * @throws EntityNotFoundException
1926
-     * @throws EE_Error
1927
-     */
1928
-    public function ticket_line_item()
1929
-    {
1930
-        $ticket = $this->ticket();
1931
-        $transaction = $this->transaction();
1932
-        $line_item = null;
1933
-        $ticket_line_items = \EEH_Line_Item::get_line_items_by_object_type_and_IDs(
1934
-            $transaction->total_line_item(),
1935
-            'Ticket',
1936
-            array($ticket->ID())
1937
-        );
1938
-        foreach ($ticket_line_items as $ticket_line_item) {
1939
-            if (
1940
-                $ticket_line_item instanceof \EE_Line_Item
1941
-                && $ticket_line_item->OBJ_type() === 'Ticket'
1942
-                && $ticket_line_item->OBJ_ID() === $ticket->ID()
1943
-            ) {
1944
-                $line_item = $ticket_line_item;
1945
-                break;
1946
-            }
1947
-        }
1948
-        if (! ($line_item instanceof \EE_Line_Item && $line_item->OBJ_type() === 'Ticket')) {
1949
-            throw new EntityNotFoundException('Line Item Ticket ID', $ticket->ID());
1950
-        }
1951
-        return $line_item;
1952
-    }
1953
-
1954
-
1955
-    /**
1956
-     * Soft Deletes this model object.
1957
-     *
1958
-     * @return boolean | int
1959
-     * @throws RuntimeException
1960
-     * @throws EE_Error
1961
-     */
1962
-    public function delete()
1963
-    {
1964
-        if ($this->update_extra_meta(EE_Registration::PRE_TRASH_REG_STATUS_KEY, $this->status_ID()) === true) {
1965
-            $this->set_status(EEM_Registration::status_id_cancelled);
1966
-        }
1967
-        return parent::delete();
1968
-    }
1969
-
1970
-
1971
-    /**
1972
-     * Restores whatever the previous status was on a registration before it was trashed (if possible)
1973
-     *
1974
-     * @throws EE_Error
1975
-     * @throws RuntimeException
1976
-     */
1977
-    public function restore()
1978
-    {
1979
-        $previous_status = $this->get_extra_meta(
1980
-            EE_Registration::PRE_TRASH_REG_STATUS_KEY,
1981
-            true,
1982
-            EEM_Registration::status_id_cancelled
1983
-        );
1984
-        if ($previous_status) {
1985
-            $this->delete_extra_meta(EE_Registration::PRE_TRASH_REG_STATUS_KEY);
1986
-            $this->set_status($previous_status);
1987
-        }
1988
-        return parent::restore();
1989
-    }
1990
-
1991
-
1992
-    /**
1993
-     * possibly toggle Registration status based on comparison of REG_paid vs REG_final_price
1994
-     *
1995
-     * @param  boolean $trigger_set_status_logic EE_Registration::set_status() can trigger additional logic
1996
-     *                                           depending on whether the reg status changes to or from "Approved"
1997
-     * @return boolean whether the Registration status was updated
1998
-     * @throws EE_Error
1999
-     * @throws RuntimeException
2000
-     */
2001
-    public function updateStatusBasedOnTotalPaid($trigger_set_status_logic = true)
2002
-    {
2003
-        $paid = $this->paid();
2004
-        $price = $this->final_price();
2005
-        switch (true) {
2006
-            // overpaid or paid
2007
-            case EEH_Money::compare_floats($paid, $price, '>'):
2008
-            case EEH_Money::compare_floats($paid, $price):
2009
-                $new_status = EEM_Registration::status_id_approved;
2010
-                break;
2011
-            //  underpaid
2012
-            case EEH_Money::compare_floats($paid, $price, '<'):
2013
-                $new_status = EEM_Registration::status_id_pending_payment;
2014
-                break;
2015
-            // uhhh Houston...
2016
-            default:
2017
-                throw new RuntimeException(
2018
-                    esc_html__('The total paid calculation for this registration is inaccurate.', 'event_espresso')
2019
-                );
2020
-        }
2021
-        if ($new_status !== $this->status_ID()) {
2022
-            if ($trigger_set_status_logic) {
2023
-                return $this->set_status($new_status);
2024
-            }
2025
-            parent::set('STS_ID', $new_status);
2026
-            return true;
2027
-        }
2028
-        return false;
2029
-    }
2030
-
2031
-
2032
-    /*************************** DEPRECATED ***************************/
2033
-
2034
-
2035
-    /**
2036
-     * @deprecated
2037
-     * @since     4.7.0
2038
-     * @access    public
2039
-     */
2040
-    public function price_paid()
2041
-    {
2042
-        EE_Error::doing_it_wrong(
2043
-            'EE_Registration::price_paid()',
2044
-            esc_html__(
2045
-                'This method is deprecated, please use EE_Registration::final_price() instead.',
2046
-                'event_espresso'
2047
-            ),
2048
-            '4.7.0'
2049
-        );
2050
-        return $this->final_price();
2051
-    }
2052
-
2053
-
2054
-    /**
2055
-     * @deprecated
2056
-     * @since     4.7.0
2057
-     * @access    public
2058
-     * @param    float $REG_final_price
2059
-     * @throws EE_Error
2060
-     * @throws RuntimeException
2061
-     */
2062
-    public function set_price_paid($REG_final_price = 0.00)
2063
-    {
2064
-        EE_Error::doing_it_wrong(
2065
-            'EE_Registration::set_price_paid()',
2066
-            esc_html__(
2067
-                'This method is deprecated, please use EE_Registration::set_final_price() instead.',
2068
-                'event_espresso'
2069
-            ),
2070
-            '4.7.0'
2071
-        );
2072
-        $this->set_final_price($REG_final_price);
2073
-    }
2074
-
2075
-
2076
-    /**
2077
-     * @deprecated
2078
-     * @since 4.7.0
2079
-     * @return string
2080
-     * @throws EE_Error
2081
-     */
2082
-    public function pretty_price_paid()
2083
-    {
2084
-        EE_Error::doing_it_wrong(
2085
-            'EE_Registration::pretty_price_paid()',
2086
-            esc_html__(
2087
-                'This method is deprecated, please use EE_Registration::pretty_final_price() instead.',
2088
-                'event_espresso'
2089
-            ),
2090
-            '4.7.0'
2091
-        );
2092
-        return $this->pretty_final_price();
2093
-    }
2094
-
2095
-
2096
-    /**
2097
-     * Gets the primary datetime related to this registration via the related Event to this registration
2098
-     *
2099
-     * @deprecated 4.9.17
2100
-     * @return EE_Datetime
2101
-     * @throws EE_Error
2102
-     * @throws EntityNotFoundException
2103
-     */
2104
-    public function get_related_primary_datetime()
2105
-    {
2106
-        EE_Error::doing_it_wrong(
2107
-            __METHOD__,
2108
-            esc_html__(
2109
-                'Use EE_Registration::get_latest_related_datetime() or EE_Registration::get_earliest_related_datetime()',
2110
-                'event_espresso'
2111
-            ),
2112
-            '4.9.17',
2113
-            '5.0.0'
2114
-        );
2115
-        return $this->event()->primary_datetime();
2116
-    }
2117
-
2118
-    /**
2119
-     * Returns the contact's name (or "Unknown" if there is no contact.)
2120
-     * @since 4.10.12.p
2121
-     * @return string
2122
-     * @throws EE_Error
2123
-     * @throws InvalidArgumentException
2124
-     * @throws InvalidDataTypeException
2125
-     * @throws InvalidInterfaceException
2126
-     * @throws ReflectionException
2127
-     */
2128
-    public function name()
2129
-    {
2130
-        return $this->attendeeName();
2131
-    }
20
+	/**
21
+	 * Used to reference when a registration has never been checked in.
22
+	 *
23
+	 * @deprecated use \EE_Checkin::status_checked_never instead
24
+	 * @type int
25
+	 */
26
+	const checkin_status_never = 2;
27
+
28
+	/**
29
+	 * Used to reference when a registration has been checked in.
30
+	 *
31
+	 * @deprecated use \EE_Checkin::status_checked_in instead
32
+	 * @type int
33
+	 */
34
+	const checkin_status_in = 1;
35
+
36
+
37
+	/**
38
+	 * Used to reference when a registration has been checked out.
39
+	 *
40
+	 * @deprecated use \EE_Checkin::status_checked_out instead
41
+	 * @type int
42
+	 */
43
+	const checkin_status_out = 0;
44
+
45
+
46
+	/**
47
+	 * extra meta key for tracking reg status os trashed registrations
48
+	 *
49
+	 * @type string
50
+	 */
51
+	const PRE_TRASH_REG_STATUS_KEY = 'pre_trash_registration_status';
52
+
53
+
54
+	/**
55
+	 * extra meta key for tracking if registration has reserved ticket
56
+	 *
57
+	 * @type string
58
+	 */
59
+	const HAS_RESERVED_TICKET_KEY = 'has_reserved_ticket';
60
+
61
+
62
+	/**
63
+	 * @param array  $props_n_values          incoming values
64
+	 * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
65
+	 *                                        used.)
66
+	 * @param array  $date_formats            incoming date_formats in an array where the first value is the
67
+	 *                                        date_format and the second value is the time format
68
+	 * @return EE_Registration
69
+	 * @throws EE_Error
70
+	 */
71
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
72
+	{
73
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
74
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
75
+	}
76
+
77
+
78
+	/**
79
+	 * @param array  $props_n_values  incoming values from the database
80
+	 * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
81
+	 *                                the website will be used.
82
+	 * @return EE_Registration
83
+	 */
84
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null)
85
+	{
86
+		return new self($props_n_values, true, $timezone);
87
+	}
88
+
89
+
90
+	/**
91
+	 *        Set Event ID
92
+	 *
93
+	 * @param        int $EVT_ID Event ID
94
+	 * @throws EE_Error
95
+	 * @throws RuntimeException
96
+	 */
97
+	public function set_event($EVT_ID = 0)
98
+	{
99
+		$this->set('EVT_ID', $EVT_ID);
100
+	}
101
+
102
+
103
+	/**
104
+	 * Overrides parent set() method so that all calls to set( 'REG_code', $REG_code ) OR set( 'STS_ID', $STS_ID ) can
105
+	 * be routed to internal methods
106
+	 *
107
+	 * @param string $field_name
108
+	 * @param mixed  $field_value
109
+	 * @param bool   $use_default
110
+	 * @throws EE_Error
111
+	 * @throws EntityNotFoundException
112
+	 * @throws InvalidArgumentException
113
+	 * @throws InvalidDataTypeException
114
+	 * @throws InvalidInterfaceException
115
+	 * @throws ReflectionException
116
+	 * @throws RuntimeException
117
+	 */
118
+	public function set($field_name, $field_value, $use_default = false)
119
+	{
120
+		switch ($field_name) {
121
+			case 'REG_code':
122
+				if (! empty($field_value) && $this->reg_code() === null) {
123
+					$this->set_reg_code($field_value, $use_default);
124
+				}
125
+				break;
126
+			case 'STS_ID':
127
+				$this->set_status($field_value, $use_default);
128
+				break;
129
+			default:
130
+				parent::set($field_name, $field_value, $use_default);
131
+		}
132
+	}
133
+
134
+
135
+	/**
136
+	 * Set Status ID
137
+	 * updates the registration status and ALSO...
138
+	 * calls reserve_registration_space() if the reg status changes TO approved from any other reg status
139
+	 * calls release_registration_space() if the reg status changes FROM approved to any other reg status
140
+	 *
141
+	 * @param string                $new_STS_ID
142
+	 * @param boolean               $use_default
143
+	 * @param ContextInterface|null $context
144
+	 * @return bool
145
+	 * @throws DomainException
146
+	 * @throws EE_Error
147
+	 * @throws EntityNotFoundException
148
+	 * @throws InvalidArgumentException
149
+	 * @throws InvalidDataTypeException
150
+	 * @throws InvalidInterfaceException
151
+	 * @throws ReflectionException
152
+	 * @throws RuntimeException
153
+	 * @throws UnexpectedEntityException
154
+	 */
155
+	public function set_status($new_STS_ID = null, $use_default = false, ContextInterface $context = null)
156
+	{
157
+		// get current REG_Status
158
+		$old_STS_ID = $this->status_ID();
159
+		// if status has changed
160
+		if (
161
+			$old_STS_ID !== $new_STS_ID // and that status has actually changed
162
+			&& ! empty($old_STS_ID) // and that old status is actually set
163
+			&& ! empty($new_STS_ID) // as well as the new status
164
+			&& $this->ID() // ensure registration is in the db
165
+		) {
166
+			// update internal status first
167
+			parent::set('STS_ID', $new_STS_ID, $use_default);
168
+			// THEN handle other changes that occur when reg status changes
169
+			// TO approved
170
+			if ($new_STS_ID === EEM_Registration::status_id_approved) {
171
+				// reserve a space by incrementing ticket and datetime sold values
172
+				$this->reserveRegistrationSpace();
173
+				do_action('AHEE__EE_Registration__set_status__to_approved', $this, $old_STS_ID, $new_STS_ID, $context);
174
+				// OR FROM  approved
175
+			} elseif ($old_STS_ID === EEM_Registration::status_id_approved) {
176
+				// release a space by decrementing ticket and datetime sold values
177
+				$this->releaseRegistrationSpace();
178
+				do_action(
179
+					'AHEE__EE_Registration__set_status__from_approved',
180
+					$this,
181
+					$old_STS_ID,
182
+					$new_STS_ID,
183
+					$context
184
+				);
185
+			}
186
+			// update status
187
+			parent::set('STS_ID', $new_STS_ID, $use_default);
188
+			$this->updateIfCanceledOrReinstated($new_STS_ID, $old_STS_ID, $context);
189
+			if ($this->statusChangeUpdatesTransaction($context)) {
190
+				$this->updateTransactionAfterStatusChange();
191
+			}
192
+			do_action('AHEE__EE_Registration__set_status__after_update', $this, $old_STS_ID, $new_STS_ID, $context);
193
+			return true;
194
+		}
195
+		// even though the old value matches the new value, it's still good to
196
+		// allow the parent set method to have a say
197
+		parent::set('STS_ID', $new_STS_ID, $use_default);
198
+		return true;
199
+	}
200
+
201
+
202
+	/**
203
+	 * update REGs and TXN when cancelled or declined registrations involved
204
+	 *
205
+	 * @param string                $new_STS_ID
206
+	 * @param string                $old_STS_ID
207
+	 * @param ContextInterface|null $context
208
+	 * @throws EE_Error
209
+	 * @throws InvalidArgumentException
210
+	 * @throws InvalidDataTypeException
211
+	 * @throws InvalidInterfaceException
212
+	 * @throws ReflectionException
213
+	 * @throws RuntimeException
214
+	 */
215
+	private function updateIfCanceledOrReinstated($new_STS_ID, $old_STS_ID, ContextInterface $context = null)
216
+	{
217
+		// these reg statuses should not be considered in any calculations involving monies owing
218
+		$closed_reg_statuses = EEM_Registration::closed_reg_statuses();
219
+		// true if registration has been cancelled or declined
220
+		$this->updateIfCanceled(
221
+			$closed_reg_statuses,
222
+			$new_STS_ID,
223
+			$old_STS_ID,
224
+			$context
225
+		);
226
+		$this->updateIfReinstated(
227
+			$closed_reg_statuses,
228
+			$new_STS_ID,
229
+			$old_STS_ID,
230
+			$context
231
+		);
232
+	}
233
+
234
+
235
+	/**
236
+	 * update REGs and TXN when cancelled or declined registrations involved
237
+	 *
238
+	 * @param array                 $closed_reg_statuses
239
+	 * @param string                $new_STS_ID
240
+	 * @param string                $old_STS_ID
241
+	 * @param ContextInterface|null $context
242
+	 * @throws EE_Error
243
+	 * @throws InvalidArgumentException
244
+	 * @throws InvalidDataTypeException
245
+	 * @throws InvalidInterfaceException
246
+	 * @throws ReflectionException
247
+	 * @throws RuntimeException
248
+	 */
249
+	private function updateIfCanceled(
250
+		array $closed_reg_statuses,
251
+		$new_STS_ID,
252
+		$old_STS_ID,
253
+		ContextInterface $context = null
254
+	) {
255
+		// true if registration has been cancelled or declined
256
+		if (
257
+			in_array($new_STS_ID, $closed_reg_statuses, true)
258
+			&& ! in_array($old_STS_ID, $closed_reg_statuses, true)
259
+		) {
260
+			/** @type EE_Registration_Processor $registration_processor */
261
+			$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
262
+			/** @type EE_Transaction_Processor $transaction_processor */
263
+			$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
264
+			// cancelled or declined registration
265
+			$registration_processor->update_registration_after_being_canceled_or_declined(
266
+				$this,
267
+				$closed_reg_statuses
268
+			);
269
+			$transaction_processor->update_transaction_after_canceled_or_declined_registration(
270
+				$this,
271
+				$closed_reg_statuses,
272
+				false
273
+			);
274
+			do_action(
275
+				'AHEE__EE_Registration__set_status__canceled_or_declined',
276
+				$this,
277
+				$old_STS_ID,
278
+				$new_STS_ID,
279
+				$context
280
+			);
281
+			return;
282
+		}
283
+	}
284
+
285
+
286
+	/**
287
+	 * update REGs and TXN when cancelled or declined registrations involved
288
+	 *
289
+	 * @param array                 $closed_reg_statuses
290
+	 * @param string                $new_STS_ID
291
+	 * @param string                $old_STS_ID
292
+	 * @param ContextInterface|null $context
293
+	 * @throws EE_Error
294
+	 * @throws InvalidArgumentException
295
+	 * @throws InvalidDataTypeException
296
+	 * @throws InvalidInterfaceException
297
+	 * @throws ReflectionException
298
+	 */
299
+	private function updateIfReinstated(
300
+		array $closed_reg_statuses,
301
+		$new_STS_ID,
302
+		$old_STS_ID,
303
+		ContextInterface $context = null
304
+	) {
305
+		// true if reinstating cancelled or declined registration
306
+		if (
307
+			in_array($old_STS_ID, $closed_reg_statuses, true)
308
+			&& ! in_array($new_STS_ID, $closed_reg_statuses, true)
309
+		) {
310
+			/** @type EE_Registration_Processor $registration_processor */
311
+			$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
312
+			/** @type EE_Transaction_Processor $transaction_processor */
313
+			$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
314
+			// reinstating cancelled or declined registration
315
+			$registration_processor->update_canceled_or_declined_registration_after_being_reinstated(
316
+				$this,
317
+				$closed_reg_statuses
318
+			);
319
+			$transaction_processor->update_transaction_after_reinstating_canceled_registration(
320
+				$this,
321
+				$closed_reg_statuses,
322
+				false
323
+			);
324
+			do_action(
325
+				'AHEE__EE_Registration__set_status__after_reinstated',
326
+				$this,
327
+				$old_STS_ID,
328
+				$new_STS_ID,
329
+				$context
330
+			);
331
+		}
332
+	}
333
+
334
+
335
+	/**
336
+	 * @param ContextInterface|null $context
337
+	 * @return bool
338
+	 */
339
+	private function statusChangeUpdatesTransaction(ContextInterface $context = null)
340
+	{
341
+		$contexts_that_do_not_update_transaction = (array) apply_filters(
342
+			'AHEE__EE_Registration__statusChangeUpdatesTransaction__contexts_that_do_not_update_transaction',
343
+			array('spco_reg_step_attendee_information_process_registrations'),
344
+			$context,
345
+			$this
346
+		);
347
+		return ! (
348
+			$context instanceof ContextInterface
349
+			&& in_array($context->slug(), $contexts_that_do_not_update_transaction, true)
350
+		);
351
+	}
352
+
353
+
354
+	/**
355
+	 * @throws EE_Error
356
+	 * @throws EntityNotFoundException
357
+	 * @throws InvalidArgumentException
358
+	 * @throws InvalidDataTypeException
359
+	 * @throws InvalidInterfaceException
360
+	 * @throws ReflectionException
361
+	 * @throws RuntimeException
362
+	 */
363
+	private function updateTransactionAfterStatusChange()
364
+	{
365
+		/** @type EE_Transaction_Payments $transaction_payments */
366
+		$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
367
+		$transaction_payments->recalculate_transaction_total($this->transaction(), false);
368
+		$this->transaction()->update_status_based_on_total_paid(true);
369
+	}
370
+
371
+
372
+	/**
373
+	 *        get Status ID
374
+	 */
375
+	public function status_ID()
376
+	{
377
+		return $this->get('STS_ID');
378
+	}
379
+
380
+
381
+	/**
382
+	 * Gets the ticket this registration is for
383
+	 *
384
+	 * @param boolean $include_archived whether to include archived tickets or not.
385
+	 *
386
+	 * @return EE_Ticket|EE_Base_Class
387
+	 * @throws EE_Error
388
+	 */
389
+	public function ticket($include_archived = true)
390
+	{
391
+		$query_params = array();
392
+		if ($include_archived) {
393
+			$query_params['default_where_conditions'] = 'none';
394
+		}
395
+		return $this->get_first_related('Ticket', $query_params);
396
+	}
397
+
398
+
399
+	/**
400
+	 * Gets the event this registration is for
401
+	 *
402
+	 * @return EE_Event
403
+	 * @throws EE_Error
404
+	 * @throws EntityNotFoundException
405
+	 */
406
+	public function event()
407
+	{
408
+		$event = $this->get_first_related('Event');
409
+		if (! $event instanceof \EE_Event) {
410
+			throw new EntityNotFoundException('Event ID', $this->event_ID());
411
+		}
412
+		return $event;
413
+	}
414
+
415
+
416
+	/**
417
+	 * Gets the "author" of the registration.  Note that for the purposes of registrations, the author will correspond
418
+	 * with the author of the event this registration is for.
419
+	 *
420
+	 * @since 4.5.0
421
+	 * @return int
422
+	 * @throws EE_Error
423
+	 * @throws EntityNotFoundException
424
+	 */
425
+	public function wp_user()
426
+	{
427
+		$event = $this->event();
428
+		if ($event instanceof EE_Event) {
429
+			return $event->wp_user();
430
+		}
431
+		return 0;
432
+	}
433
+
434
+
435
+	/**
436
+	 * increments this registration's related ticket sold and corresponding datetime sold values
437
+	 *
438
+	 * @return void
439
+	 * @throws DomainException
440
+	 * @throws EE_Error
441
+	 * @throws EntityNotFoundException
442
+	 * @throws InvalidArgumentException
443
+	 * @throws InvalidDataTypeException
444
+	 * @throws InvalidInterfaceException
445
+	 * @throws ReflectionException
446
+	 * @throws UnexpectedEntityException
447
+	 */
448
+	private function reserveRegistrationSpace()
449
+	{
450
+		// reserved ticket and datetime counts will be decremented as sold counts are incremented
451
+		// so stop tracking that this reg has a ticket reserved
452
+		$this->release_reserved_ticket(false, "REG: {$this->ID()} (ln:" . __LINE__ . ')');
453
+		$ticket = $this->ticket();
454
+		$ticket->increaseSold();
455
+		// possibly set event status to sold out
456
+		$this->event()->perform_sold_out_status_check();
457
+	}
458
+
459
+
460
+	/**
461
+	 * decrements (subtracts) this registration's related ticket sold and corresponding datetime sold values
462
+	 *
463
+	 * @return void
464
+	 * @throws DomainException
465
+	 * @throws EE_Error
466
+	 * @throws EntityNotFoundException
467
+	 * @throws InvalidArgumentException
468
+	 * @throws InvalidDataTypeException
469
+	 * @throws InvalidInterfaceException
470
+	 * @throws ReflectionException
471
+	 * @throws UnexpectedEntityException
472
+	 */
473
+	private function releaseRegistrationSpace()
474
+	{
475
+		$ticket = $this->ticket();
476
+		$ticket->decreaseSold();
477
+		// possibly change event status from sold out back to previous status
478
+		$this->event()->perform_sold_out_status_check();
479
+	}
480
+
481
+
482
+	/**
483
+	 * tracks this registration's ticket reservation in extra meta
484
+	 * and can increment related ticket reserved and corresponding datetime reserved values
485
+	 *
486
+	 * @param bool $update_ticket if true, will increment ticket and datetime reserved count
487
+	 * @return void
488
+	 * @throws EE_Error
489
+	 * @throws InvalidArgumentException
490
+	 * @throws InvalidDataTypeException
491
+	 * @throws InvalidInterfaceException
492
+	 * @throws ReflectionException
493
+	 */
494
+	public function reserve_ticket($update_ticket = false, $source = 'unknown')
495
+	{
496
+		// only reserve ticket if space is not currently reserved
497
+		if ((bool) $this->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true) !== true) {
498
+			$this->update_extra_meta('reserve_ticket', "{$this->ticket_ID()} from {$source}");
499
+			// IMPORTANT !!!
500
+			// although checking $update_ticket first would be more efficient,
501
+			// we NEED to ALWAYS call update_extra_meta(), which is why that is done first
502
+			if (
503
+				$this->update_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true)
504
+				&& $update_ticket
505
+			) {
506
+				$ticket = $this->ticket();
507
+				$ticket->increaseReserved(1, "REG: {$this->ID()} (ln:" . __LINE__ . ')');
508
+				$ticket->save();
509
+			}
510
+		}
511
+	}
512
+
513
+
514
+	/**
515
+	 * stops tracking this registration's ticket reservation in extra meta
516
+	 * decrements (subtracts) related ticket reserved and corresponding datetime reserved values
517
+	 *
518
+	 * @param bool $update_ticket if true, will decrement ticket and datetime reserved count
519
+	 * @return void
520
+	 * @throws EE_Error
521
+	 * @throws InvalidArgumentException
522
+	 * @throws InvalidDataTypeException
523
+	 * @throws InvalidInterfaceException
524
+	 * @throws ReflectionException
525
+	 */
526
+	public function release_reserved_ticket($update_ticket = false, $source = 'unknown')
527
+	{
528
+		// only release ticket if space is currently reserved
529
+		if ((bool) $this->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true) === true) {
530
+			$this->update_extra_meta('release_reserved_ticket', "{$this->ticket_ID()} from {$source}");
531
+			// IMPORTANT !!!
532
+			// although checking $update_ticket first would be more efficient,
533
+			// we NEED to ALWAYS call update_extra_meta(), which is why that is done first
534
+			if (
535
+				$this->update_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, false)
536
+				&& $update_ticket
537
+			) {
538
+				$ticket = $this->ticket();
539
+				$ticket->decreaseReserved(1, true, "REG: {$this->ID()} (ln:" . __LINE__ . ')');
540
+			}
541
+		}
542
+	}
543
+
544
+
545
+	/**
546
+	 * Set Attendee ID
547
+	 *
548
+	 * @param        int $ATT_ID Attendee ID
549
+	 * @throws EE_Error
550
+	 * @throws RuntimeException
551
+	 */
552
+	public function set_attendee_id($ATT_ID = 0)
553
+	{
554
+		$this->set('ATT_ID', $ATT_ID);
555
+	}
556
+
557
+
558
+	/**
559
+	 *        Set Transaction ID
560
+	 *
561
+	 * @param        int $TXN_ID Transaction ID
562
+	 * @throws EE_Error
563
+	 * @throws RuntimeException
564
+	 */
565
+	public function set_transaction_id($TXN_ID = 0)
566
+	{
567
+		$this->set('TXN_ID', $TXN_ID);
568
+	}
569
+
570
+
571
+	/**
572
+	 *        Set Session
573
+	 *
574
+	 * @param    string $REG_session PHP Session ID
575
+	 * @throws EE_Error
576
+	 * @throws RuntimeException
577
+	 */
578
+	public function set_session($REG_session = '')
579
+	{
580
+		$this->set('REG_session', $REG_session);
581
+	}
582
+
583
+
584
+	/**
585
+	 *        Set Registration URL Link
586
+	 *
587
+	 * @param    string $REG_url_link Registration URL Link
588
+	 * @throws EE_Error
589
+	 * @throws RuntimeException
590
+	 */
591
+	public function set_reg_url_link($REG_url_link = '')
592
+	{
593
+		$this->set('REG_url_link', $REG_url_link);
594
+	}
595
+
596
+
597
+	/**
598
+	 *        Set Attendee Counter
599
+	 *
600
+	 * @param        int $REG_count Primary Attendee
601
+	 * @throws EE_Error
602
+	 * @throws RuntimeException
603
+	 */
604
+	public function set_count($REG_count = 1)
605
+	{
606
+		$this->set('REG_count', $REG_count);
607
+	}
608
+
609
+
610
+	/**
611
+	 *        Set Group Size
612
+	 *
613
+	 * @param        boolean $REG_group_size Group Registration
614
+	 * @throws EE_Error
615
+	 * @throws RuntimeException
616
+	 */
617
+	public function set_group_size($REG_group_size = false)
618
+	{
619
+		$this->set('REG_group_size', $REG_group_size);
620
+	}
621
+
622
+
623
+	/**
624
+	 *    is_not_approved -  convenience method that returns TRUE if REG status ID ==
625
+	 *    EEM_Registration::status_id_not_approved
626
+	 *
627
+	 * @return        boolean
628
+	 */
629
+	public function is_not_approved()
630
+	{
631
+		return $this->status_ID() == EEM_Registration::status_id_not_approved ? true : false;
632
+	}
633
+
634
+
635
+	/**
636
+	 *    is_pending_payment -  convenience method that returns TRUE if REG status ID ==
637
+	 *    EEM_Registration::status_id_pending_payment
638
+	 *
639
+	 * @return        boolean
640
+	 */
641
+	public function is_pending_payment()
642
+	{
643
+		return $this->status_ID() == EEM_Registration::status_id_pending_payment ? true : false;
644
+	}
645
+
646
+
647
+	/**
648
+	 *    is_approved -  convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_approved
649
+	 *
650
+	 * @return        boolean
651
+	 */
652
+	public function is_approved()
653
+	{
654
+		return $this->status_ID() == EEM_Registration::status_id_approved ? true : false;
655
+	}
656
+
657
+
658
+	/**
659
+	 *    is_cancelled -  convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_cancelled
660
+	 *
661
+	 * @return        boolean
662
+	 */
663
+	public function is_cancelled()
664
+	{
665
+		return $this->status_ID() == EEM_Registration::status_id_cancelled ? true : false;
666
+	}
667
+
668
+
669
+	/**
670
+	 *    is_declined -  convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_declined
671
+	 *
672
+	 * @return        boolean
673
+	 */
674
+	public function is_declined()
675
+	{
676
+		return $this->status_ID() == EEM_Registration::status_id_declined ? true : false;
677
+	}
678
+
679
+
680
+	/**
681
+	 *    is_incomplete -  convenience method that returns TRUE if REG status ID ==
682
+	 *    EEM_Registration::status_id_incomplete
683
+	 *
684
+	 * @return        boolean
685
+	 */
686
+	public function is_incomplete()
687
+	{
688
+		return $this->status_ID() == EEM_Registration::status_id_incomplete ? true : false;
689
+	}
690
+
691
+
692
+	/**
693
+	 *        Set Registration Date
694
+	 *
695
+	 * @param        mixed ( int or string ) $REG_date Registration Date - Unix timestamp or string representation of
696
+	 *                                                 Date
697
+	 * @throws EE_Error
698
+	 * @throws RuntimeException
699
+	 */
700
+	public function set_reg_date($REG_date = false)
701
+	{
702
+		$this->set('REG_date', $REG_date);
703
+	}
704
+
705
+
706
+	/**
707
+	 *    Set final price owing for this registration after all ticket/price modifications
708
+	 *
709
+	 * @access    public
710
+	 * @param    float $REG_final_price
711
+	 * @throws EE_Error
712
+	 * @throws RuntimeException
713
+	 */
714
+	public function set_final_price($REG_final_price = 0.00)
715
+	{
716
+		$this->set('REG_final_price', $REG_final_price);
717
+	}
718
+
719
+
720
+	/**
721
+	 *    Set amount paid towards this registration's final price
722
+	 *
723
+	 * @access    public
724
+	 * @param    float $REG_paid
725
+	 * @throws EE_Error
726
+	 * @throws RuntimeException
727
+	 */
728
+	public function set_paid($REG_paid = 0.00)
729
+	{
730
+		$this->set('REG_paid', $REG_paid);
731
+	}
732
+
733
+
734
+	/**
735
+	 *        Attendee Is Going
736
+	 *
737
+	 * @param        boolean $REG_att_is_going Attendee Is Going
738
+	 * @throws EE_Error
739
+	 * @throws RuntimeException
740
+	 */
741
+	public function set_att_is_going($REG_att_is_going = false)
742
+	{
743
+		$this->set('REG_att_is_going', $REG_att_is_going);
744
+	}
745
+
746
+
747
+	/**
748
+	 * Gets the related attendee
749
+	 *
750
+	 * @return EE_Attendee
751
+	 * @throws EE_Error
752
+	 */
753
+	public function attendee()
754
+	{
755
+		return $this->get_first_related('Attendee');
756
+	}
757
+
758
+	/**
759
+	 * Gets the name of the attendee.
760
+	 * @since 4.10.12.p
761
+	 * @param bool $apply_html_entities set to true if you want to use HTML entities.
762
+	 * @return string
763
+	 * @throws EE_Error
764
+	 * @throws InvalidArgumentException
765
+	 * @throws InvalidDataTypeException
766
+	 * @throws InvalidInterfaceException
767
+	 * @throws ReflectionException
768
+	 */
769
+	public function attendeeName($apply_html_entities = false)
770
+	{
771
+		$attendee = $this->get_first_related('Attendee');
772
+		if ($attendee instanceof EE_Attendee) {
773
+			$attendee_name = $attendee->full_name($apply_html_entities);
774
+		} else {
775
+			$attendee_name = esc_html__('Unknown', 'event_espresso');
776
+		}
777
+		return $attendee_name;
778
+	}
779
+
780
+
781
+	/**
782
+	 *        get Event ID
783
+	 */
784
+	public function event_ID()
785
+	{
786
+		return $this->get('EVT_ID');
787
+	}
788
+
789
+
790
+	/**
791
+	 *        get Event ID
792
+	 */
793
+	public function event_name()
794
+	{
795
+		$event = $this->event_obj();
796
+		if ($event) {
797
+			return $event->name();
798
+		} else {
799
+			return null;
800
+		}
801
+	}
802
+
803
+
804
+	/**
805
+	 * Fetches the event this registration is for
806
+	 *
807
+	 * @return EE_Event
808
+	 * @throws EE_Error
809
+	 */
810
+	public function event_obj()
811
+	{
812
+		return $this->get_first_related('Event');
813
+	}
814
+
815
+
816
+	/**
817
+	 *        get Attendee ID
818
+	 */
819
+	public function attendee_ID()
820
+	{
821
+		return $this->get('ATT_ID');
822
+	}
823
+
824
+
825
+	/**
826
+	 *        get PHP Session ID
827
+	 */
828
+	public function session_ID()
829
+	{
830
+		return $this->get('REG_session');
831
+	}
832
+
833
+
834
+	/**
835
+	 * Gets the string which represents the URL trigger for the receipt template in the message template system.
836
+	 *
837
+	 * @param string $messenger 'pdf' or 'html'.  Default 'html'.
838
+	 * @return string
839
+	 */
840
+	public function receipt_url($messenger = 'html')
841
+	{
842
+
843
+		/**
844
+		 * The below will be deprecated one version after this.  We check first if there is a custom receipt template
845
+		 * already in use on old system.  If there is then we just return the standard url for it.
846
+		 *
847
+		 * @since 4.5.0
848
+		 */
849
+		$template_relative_path = 'modules/gateways/Invoice/lib/templates/receipt_body.template.php';
850
+		$has_custom = EEH_Template::locate_template(
851
+			$template_relative_path,
852
+			array(),
853
+			true,
854
+			true,
855
+			true
856
+		);
857
+
858
+		if ($has_custom) {
859
+			return add_query_arg(array('receipt' => 'true'), $this->invoice_url('launch'));
860
+		}
861
+		return apply_filters('FHEE__EE_Registration__receipt_url__receipt_url', '', $this, $messenger, 'receipt');
862
+	}
863
+
864
+
865
+	/**
866
+	 * Gets the string which represents the URL trigger for the invoice template in the message template system.
867
+	 *
868
+	 * @param string $messenger 'pdf' or 'html'.  Default 'html'.
869
+	 * @return string
870
+	 * @throws EE_Error
871
+	 */
872
+	public function invoice_url($messenger = 'html')
873
+	{
874
+		/**
875
+		 * The below will be deprecated one version after this.  We check first if there is a custom invoice template
876
+		 * already in use on old system.  If there is then we just return the standard url for it.
877
+		 *
878
+		 * @since 4.5.0
879
+		 */
880
+		$template_relative_path = 'modules/gateways/Invoice/lib/templates/invoice_body.template.php';
881
+		$has_custom = EEH_Template::locate_template(
882
+			$template_relative_path,
883
+			array(),
884
+			true,
885
+			true,
886
+			true
887
+		);
888
+
889
+		if ($has_custom) {
890
+			if ($messenger == 'html') {
891
+				return $this->invoice_url('launch');
892
+			}
893
+			$route = $messenger == 'download' || $messenger == 'pdf' ? 'download_invoice' : 'launch_invoice';
894
+
895
+			$query_args = array('ee' => $route, 'id' => $this->reg_url_link());
896
+			if ($messenger == 'html') {
897
+				$query_args['html'] = true;
898
+			}
899
+			return add_query_arg($query_args, get_permalink(EE_Registry::instance()->CFG->core->thank_you_page_id));
900
+		}
901
+		return apply_filters('FHEE__EE_Registration__invoice_url__invoice_url', '', $this, $messenger, 'invoice');
902
+	}
903
+
904
+
905
+	/**
906
+	 * get Registration URL Link
907
+	 *
908
+	 * @access public
909
+	 * @return string
910
+	 * @throws EE_Error
911
+	 */
912
+	public function reg_url_link()
913
+	{
914
+		return (string) $this->get('REG_url_link');
915
+	}
916
+
917
+
918
+	/**
919
+	 * Echoes out invoice_url()
920
+	 *
921
+	 * @param string $type 'download','launch', or 'html' (default is 'launch')
922
+	 * @return void
923
+	 * @throws EE_Error
924
+	 */
925
+	public function e_invoice_url($type = 'launch')
926
+	{
927
+		echo esc_url_raw($this->invoice_url($type));
928
+	}
929
+
930
+
931
+	/**
932
+	 * Echoes out payment_overview_url
933
+	 */
934
+	public function e_payment_overview_url()
935
+	{
936
+		echo esc_url_raw($this->payment_overview_url());
937
+	}
938
+
939
+
940
+	/**
941
+	 * Gets the URL for the checkout payment options reg step
942
+	 * with this registration's REG_url_link added as a query parameter
943
+	 *
944
+	 * @param bool $clear_session Set to true when you want to clear the session on revisiting the
945
+	 *                            payment overview url.
946
+	 * @return string
947
+	 * @throws InvalidInterfaceException
948
+	 * @throws InvalidDataTypeException
949
+	 * @throws EE_Error
950
+	 * @throws InvalidArgumentException
951
+	 */
952
+	public function payment_overview_url($clear_session = false)
953
+	{
954
+		return add_query_arg(
955
+			(array) apply_filters(
956
+				'FHEE__EE_Registration__payment_overview_url__query_args',
957
+				array(
958
+					'e_reg_url_link' => $this->reg_url_link(),
959
+					'step'           => 'payment_options',
960
+					'revisit'        => true,
961
+					'clear_session'  => (bool) $clear_session,
962
+				),
963
+				$this
964
+			),
965
+			EE_Registry::instance()->CFG->core->reg_page_url()
966
+		);
967
+	}
968
+
969
+
970
+	/**
971
+	 * Gets the URL for the checkout attendee information reg step
972
+	 * with this registration's REG_url_link added as a query parameter
973
+	 *
974
+	 * @return string
975
+	 * @throws InvalidInterfaceException
976
+	 * @throws InvalidDataTypeException
977
+	 * @throws EE_Error
978
+	 * @throws InvalidArgumentException
979
+	 */
980
+	public function edit_attendee_information_url()
981
+	{
982
+		return add_query_arg(
983
+			(array) apply_filters(
984
+				'FHEE__EE_Registration__edit_attendee_information_url__query_args',
985
+				array(
986
+					'e_reg_url_link' => $this->reg_url_link(),
987
+					'step'           => 'attendee_information',
988
+					'revisit'        => true,
989
+				),
990
+				$this
991
+			),
992
+			EE_Registry::instance()->CFG->core->reg_page_url()
993
+		);
994
+	}
995
+
996
+
997
+	/**
998
+	 * Simply generates and returns the appropriate admin_url link to edit this registration
999
+	 *
1000
+	 * @return string
1001
+	 * @throws EE_Error
1002
+	 */
1003
+	public function get_admin_edit_url()
1004
+	{
1005
+		return EEH_URL::add_query_args_and_nonce(
1006
+			array(
1007
+				'page'    => 'espresso_registrations',
1008
+				'action'  => 'view_registration',
1009
+				'_REG_ID' => $this->ID(),
1010
+			),
1011
+			admin_url('admin.php')
1012
+		);
1013
+	}
1014
+
1015
+
1016
+	/**
1017
+	 *    is_primary_registrant?
1018
+	 */
1019
+	public function is_primary_registrant()
1020
+	{
1021
+		return $this->get('REG_count') === 1 ? true : false;
1022
+	}
1023
+
1024
+
1025
+	/**
1026
+	 * This returns the primary registration object for this registration group (which may be this object).
1027
+	 *
1028
+	 * @return EE_Registration
1029
+	 * @throws EE_Error
1030
+	 */
1031
+	public function get_primary_registration()
1032
+	{
1033
+		if ($this->is_primary_registrant()) {
1034
+			return $this;
1035
+		}
1036
+
1037
+		// k reg_count !== 1 so let's get the EE_Registration object matching this txn_id and reg_count == 1
1038
+		/** @var EE_Registration $primary_registrant */
1039
+		$primary_registrant = EEM_Registration::instance()->get_one(
1040
+			array(
1041
+				array(
1042
+					'TXN_ID'    => $this->transaction_ID(),
1043
+					'REG_count' => 1,
1044
+				),
1045
+			)
1046
+		);
1047
+		return $primary_registrant;
1048
+	}
1049
+
1050
+
1051
+	/**
1052
+	 *        get  Attendee Number
1053
+	 *
1054
+	 * @access        public
1055
+	 */
1056
+	public function count()
1057
+	{
1058
+		return $this->get('REG_count');
1059
+	}
1060
+
1061
+
1062
+	/**
1063
+	 *        get Group Size
1064
+	 */
1065
+	public function group_size()
1066
+	{
1067
+		return $this->get('REG_group_size');
1068
+	}
1069
+
1070
+
1071
+	/**
1072
+	 *        get Registration Date
1073
+	 */
1074
+	public function date()
1075
+	{
1076
+		return $this->get('REG_date');
1077
+	}
1078
+
1079
+
1080
+	/**
1081
+	 * gets a pretty date
1082
+	 *
1083
+	 * @param string $date_format
1084
+	 * @param string $time_format
1085
+	 * @return string
1086
+	 * @throws EE_Error
1087
+	 */
1088
+	public function pretty_date($date_format = null, $time_format = null)
1089
+	{
1090
+		return $this->get_datetime('REG_date', $date_format, $time_format);
1091
+	}
1092
+
1093
+
1094
+	/**
1095
+	 * final_price
1096
+	 * the registration's share of the transaction total, so that the
1097
+	 * sum of all the transaction's REG_final_prices equal the transaction's total
1098
+	 *
1099
+	 * @return float
1100
+	 * @throws EE_Error
1101
+	 */
1102
+	public function final_price()
1103
+	{
1104
+		return $this->get('REG_final_price');
1105
+	}
1106
+
1107
+
1108
+	/**
1109
+	 * pretty_final_price
1110
+	 *  final price as formatted string, with correct decimal places and currency symbol
1111
+	 *
1112
+	 * @return string
1113
+	 * @throws EE_Error
1114
+	 */
1115
+	public function pretty_final_price()
1116
+	{
1117
+		return $this->get_pretty('REG_final_price');
1118
+	}
1119
+
1120
+
1121
+	/**
1122
+	 * get paid (yeah)
1123
+	 *
1124
+	 * @return float
1125
+	 * @throws EE_Error
1126
+	 */
1127
+	public function paid()
1128
+	{
1129
+		return $this->get('REG_paid');
1130
+	}
1131
+
1132
+
1133
+	/**
1134
+	 * pretty_paid
1135
+	 *
1136
+	 * @return float
1137
+	 * @throws EE_Error
1138
+	 */
1139
+	public function pretty_paid()
1140
+	{
1141
+		return $this->get_pretty('REG_paid');
1142
+	}
1143
+
1144
+
1145
+	/**
1146
+	 * owes_monies_and_can_pay
1147
+	 * whether or not this registration has monies owing and it's' status allows payment
1148
+	 *
1149
+	 * @param array $requires_payment
1150
+	 * @return bool
1151
+	 * @throws EE_Error
1152
+	 */
1153
+	public function owes_monies_and_can_pay($requires_payment = array())
1154
+	{
1155
+		// these reg statuses require payment (if event is not free)
1156
+		$requires_payment = ! empty($requires_payment)
1157
+			? $requires_payment
1158
+			: EEM_Registration::reg_statuses_that_allow_payment();
1159
+		if (
1160
+			in_array($this->status_ID(), $requires_payment) &&
1161
+			$this->final_price() != 0 &&
1162
+			$this->final_price() != $this->paid()
1163
+		) {
1164
+			return true;
1165
+		} else {
1166
+			return false;
1167
+		}
1168
+	}
1169
+
1170
+
1171
+	/**
1172
+	 * Prints out the return value of $this->pretty_status()
1173
+	 *
1174
+	 * @param bool $show_icons
1175
+	 * @return void
1176
+	 * @throws EE_Error
1177
+	 */
1178
+	public function e_pretty_status($show_icons = false)
1179
+	{
1180
+		echo $this->pretty_status($show_icons); // already escaped
1181
+	}
1182
+
1183
+
1184
+	/**
1185
+	 * Returns a nice version of the status for displaying to customers
1186
+	 *
1187
+	 * @param bool $show_icons
1188
+	 * @return string
1189
+	 * @throws EE_Error
1190
+	 */
1191
+	public function pretty_status($show_icons = false)
1192
+	{
1193
+		$status = EEM_Status::instance()->localized_status(
1194
+			array($this->status_ID() => esc_html__('unknown', 'event_espresso')),
1195
+			false,
1196
+			'sentence'
1197
+		);
1198
+		$icon = '';
1199
+		switch ($this->status_ID()) {
1200
+			case EEM_Registration::status_id_approved:
1201
+				$icon = $show_icons
1202
+					? '<span class="dashicons dashicons-star-filled ee-icon-size-16 green-text"></span>'
1203
+					: '';
1204
+				break;
1205
+			case EEM_Registration::status_id_pending_payment:
1206
+				$icon = $show_icons
1207
+					? '<span class="dashicons dashicons-star-half ee-icon-size-16 orange-text"></span>'
1208
+					: '';
1209
+				break;
1210
+			case EEM_Registration::status_id_not_approved:
1211
+				$icon = $show_icons
1212
+					? '<span class="dashicons dashicons-marker ee-icon-size-16 orange-text"></span>'
1213
+					: '';
1214
+				break;
1215
+			case EEM_Registration::status_id_cancelled:
1216
+				$icon = $show_icons
1217
+					? '<span class="dashicons dashicons-no ee-icon-size-16 lt-grey-text"></span>'
1218
+					: '';
1219
+				break;
1220
+			case EEM_Registration::status_id_incomplete:
1221
+				$icon = $show_icons
1222
+					? '<span class="dashicons dashicons-no ee-icon-size-16 lt-orange-text"></span>'
1223
+					: '';
1224
+				break;
1225
+			case EEM_Registration::status_id_declined:
1226
+				$icon = $show_icons
1227
+					? '<span class="dashicons dashicons-no ee-icon-size-16 red-text"></span>'
1228
+					: '';
1229
+				break;
1230
+			case EEM_Registration::status_id_wait_list:
1231
+				$icon = $show_icons
1232
+					? '<span class="dashicons dashicons-clipboard ee-icon-size-16 purple-text"></span>'
1233
+					: '';
1234
+				break;
1235
+		}
1236
+		return $icon . $status[ $this->status_ID() ];
1237
+	}
1238
+
1239
+
1240
+	/**
1241
+	 *        get Attendee Is Going
1242
+	 */
1243
+	public function att_is_going()
1244
+	{
1245
+		return $this->get('REG_att_is_going');
1246
+	}
1247
+
1248
+
1249
+	/**
1250
+	 * Gets related answers
1251
+	 *
1252
+	 * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1253
+	 * @return EE_Answer[]
1254
+	 * @throws EE_Error
1255
+	 */
1256
+	public function answers($query_params = null)
1257
+	{
1258
+		return $this->get_many_related('Answer', $query_params);
1259
+	}
1260
+
1261
+
1262
+	/**
1263
+	 * Gets the registration's answer value to the specified question
1264
+	 * (either the question's ID or a question object)
1265
+	 *
1266
+	 * @param EE_Question|int $question
1267
+	 * @param bool            $pretty_value
1268
+	 * @return array|string if pretty_value= true, the result will always be a string
1269
+	 * (because the answer might be an array of answer values, so passing pretty_value=true
1270
+	 * will convert it into some kind of string)
1271
+	 * @throws EE_Error
1272
+	 */
1273
+	public function answer_value_to_question($question, $pretty_value = true)
1274
+	{
1275
+		$question_id = EEM_Question::instance()->ensure_is_ID($question);
1276
+		return EEM_Answer::instance()->get_answer_value_to_question($this, $question_id, $pretty_value);
1277
+	}
1278
+
1279
+
1280
+	/**
1281
+	 * question_groups
1282
+	 * returns an array of EE_Question_Group objects for this registration
1283
+	 *
1284
+	 * @return EE_Question_Group[]
1285
+	 * @throws EE_Error
1286
+	 * @throws InvalidArgumentException
1287
+	 * @throws InvalidDataTypeException
1288
+	 * @throws InvalidInterfaceException
1289
+	 * @throws ReflectionException
1290
+	 */
1291
+	public function question_groups()
1292
+	{
1293
+		return EEM_Event::instance()->get_question_groups_for_event($this->event_ID(), $this);
1294
+	}
1295
+
1296
+
1297
+	/**
1298
+	 * count_question_groups
1299
+	 * returns a count of the number of EE_Question_Group objects for this registration
1300
+	 *
1301
+	 * @return int
1302
+	 * @throws EE_Error
1303
+	 * @throws EntityNotFoundException
1304
+	 * @throws InvalidArgumentException
1305
+	 * @throws InvalidDataTypeException
1306
+	 * @throws InvalidInterfaceException
1307
+	 * @throws ReflectionException
1308
+	 */
1309
+	public function count_question_groups()
1310
+	{
1311
+		return EEM_Event::instance()->count_related(
1312
+			$this->event_ID(),
1313
+			'Question_Group',
1314
+			[
1315
+				[
1316
+					'Event_Question_Group.'
1317
+					. EEM_Event_Question_Group::instance()->fieldNameForContext($this->is_primary_registrant()) => true,
1318
+				]
1319
+			]
1320
+		);
1321
+	}
1322
+
1323
+
1324
+	/**
1325
+	 * Returns the registration date in the 'standard' string format
1326
+	 * (function may be improved in the future to allow for different formats and timezones)
1327
+	 *
1328
+	 * @return string
1329
+	 * @throws EE_Error
1330
+	 */
1331
+	public function reg_date()
1332
+	{
1333
+		return $this->get_datetime('REG_date');
1334
+	}
1335
+
1336
+
1337
+	/**
1338
+	 * Gets the datetime-ticket for this registration (ie, it can be used to isolate
1339
+	 * the ticket this registration purchased, or the datetime they have registered
1340
+	 * to attend)
1341
+	 *
1342
+	 * @return EE_Datetime_Ticket
1343
+	 * @throws EE_Error
1344
+	 */
1345
+	public function datetime_ticket()
1346
+	{
1347
+		return $this->get_first_related('Datetime_Ticket');
1348
+	}
1349
+
1350
+
1351
+	/**
1352
+	 * Sets the registration's datetime_ticket.
1353
+	 *
1354
+	 * @param EE_Datetime_Ticket $datetime_ticket
1355
+	 * @return EE_Datetime_Ticket
1356
+	 * @throws EE_Error
1357
+	 */
1358
+	public function set_datetime_ticket($datetime_ticket)
1359
+	{
1360
+		return $this->_add_relation_to($datetime_ticket, 'Datetime_Ticket');
1361
+	}
1362
+
1363
+	/**
1364
+	 * Gets deleted
1365
+	 *
1366
+	 * @return bool
1367
+	 * @throws EE_Error
1368
+	 */
1369
+	public function deleted()
1370
+	{
1371
+		return $this->get('REG_deleted');
1372
+	}
1373
+
1374
+	/**
1375
+	 * Sets deleted
1376
+	 *
1377
+	 * @param boolean $deleted
1378
+	 * @return bool
1379
+	 * @throws EE_Error
1380
+	 * @throws RuntimeException
1381
+	 */
1382
+	public function set_deleted($deleted)
1383
+	{
1384
+		if ($deleted) {
1385
+			$this->delete();
1386
+		} else {
1387
+			$this->restore();
1388
+		}
1389
+	}
1390
+
1391
+
1392
+	/**
1393
+	 * Get the status object of this object
1394
+	 *
1395
+	 * @return EE_Status
1396
+	 * @throws EE_Error
1397
+	 */
1398
+	public function status_obj()
1399
+	{
1400
+		return $this->get_first_related('Status');
1401
+	}
1402
+
1403
+
1404
+	/**
1405
+	 * Returns the number of times this registration has checked into any of the datetimes
1406
+	 * its available for
1407
+	 *
1408
+	 * @return int
1409
+	 * @throws EE_Error
1410
+	 */
1411
+	public function count_checkins()
1412
+	{
1413
+		return $this->get_model()->count_related($this, 'Checkin');
1414
+	}
1415
+
1416
+
1417
+	/**
1418
+	 * Returns the number of current Check-ins this registration is checked into for any of the datetimes the
1419
+	 * registration is for.  Note, this is ONLY checked in (does not include checkedout)
1420
+	 *
1421
+	 * @return int
1422
+	 * @throws EE_Error
1423
+	 */
1424
+	public function count_checkins_not_checkedout()
1425
+	{
1426
+		return $this->get_model()->count_related($this, 'Checkin', array(array('CHK_in' => 1)));
1427
+	}
1428
+
1429
+
1430
+	/**
1431
+	 * The purpose of this method is simply to check whether this registration can checkin to the given datetime.
1432
+	 *
1433
+	 * @param int | EE_Datetime $DTT_OR_ID      The datetime the registration is being checked against
1434
+	 * @param bool              $check_approved This is used to indicate whether the caller wants can_checkin to also
1435
+	 *                                          consider registration status as well as datetime access.
1436
+	 * @return bool
1437
+	 * @throws EE_Error
1438
+	 */
1439
+	public function can_checkin($DTT_OR_ID, $check_approved = true)
1440
+	{
1441
+		$DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID);
1442
+
1443
+		// first check registration status
1444
+		if (($check_approved && ! $this->is_approved()) || ! $DTT_ID) {
1445
+			return false;
1446
+		}
1447
+		// is there a datetime ticket that matches this dtt_ID?
1448
+		if (
1449
+			! (EEM_Datetime_Ticket::instance()->exists(
1450
+				array(
1451
+				array(
1452
+					'TKT_ID' => $this->get('TKT_ID'),
1453
+					'DTT_ID' => $DTT_ID,
1454
+				),
1455
+				)
1456
+			))
1457
+		) {
1458
+			return false;
1459
+		}
1460
+
1461
+		// final check is against TKT_uses
1462
+		return $this->verify_can_checkin_against_TKT_uses($DTT_ID);
1463
+	}
1464
+
1465
+
1466
+	/**
1467
+	 * This method verifies whether the user can checkin for the given datetime considering the max uses value set on
1468
+	 * the ticket. To do this,  a query is done to get the count of the datetime records already checked into.  If the
1469
+	 * datetime given does not have a check-in record and checking in for that datetime will exceed the allowed uses,
1470
+	 * then return false.  Otherwise return true.
1471
+	 *
1472
+	 * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against
1473
+	 * @return bool true means can checkin.  false means cannot checkin.
1474
+	 * @throws EE_Error
1475
+	 */
1476
+	public function verify_can_checkin_against_TKT_uses($DTT_OR_ID)
1477
+	{
1478
+		$DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID);
1479
+
1480
+		if (! $DTT_ID) {
1481
+			return false;
1482
+		}
1483
+
1484
+		$max_uses = $this->ticket() instanceof EE_Ticket ? $this->ticket()->uses() : EE_INF;
1485
+
1486
+		// if max uses is not set or equals infinity then return true cause its not a factor for whether user can
1487
+		// check-in or not.
1488
+		if (! $max_uses || $max_uses === EE_INF) {
1489
+			return true;
1490
+		}
1491
+
1492
+		// does this datetime have a checkin record?  If so, then the dtt count has already been verified so we can just
1493
+		// go ahead and toggle.
1494
+		if (EEM_Checkin::instance()->exists(array(array('REG_ID' => $this->ID(), 'DTT_ID' => $DTT_ID)))) {
1495
+			return true;
1496
+		}
1497
+
1498
+		// made it here so the last check is whether the number of checkins per unique datetime on this registration
1499
+		// disallows further check-ins.
1500
+		$count_unique_dtt_checkins = EEM_Checkin::instance()->count(
1501
+			array(
1502
+				array(
1503
+					'REG_ID' => $this->ID(),
1504
+					'CHK_in' => true,
1505
+				),
1506
+			),
1507
+			'DTT_ID',
1508
+			true
1509
+		);
1510
+		// checkins have already reached their max number of uses
1511
+		// so registrant can NOT checkin
1512
+		if ($count_unique_dtt_checkins >= $max_uses) {
1513
+			EE_Error::add_error(
1514
+				esc_html__(
1515
+					'Check-in denied because number of datetime uses for the ticket has been reached or exceeded.',
1516
+					'event_espresso'
1517
+				),
1518
+				__FILE__,
1519
+				__FUNCTION__,
1520
+				__LINE__
1521
+			);
1522
+			return false;
1523
+		}
1524
+		return true;
1525
+	}
1526
+
1527
+
1528
+	/**
1529
+	 * toggle Check-in status for this registration
1530
+	 * Check-ins are toggled in the following order:
1531
+	 * never checked in -> checked in
1532
+	 * checked in -> checked out
1533
+	 * checked out -> checked in
1534
+	 *
1535
+	 * @param  int $DTT_ID  include specific datetime to toggle Check-in for.
1536
+	 *                      If not included or null, then it is assumed latest datetime is being toggled.
1537
+	 * @param bool $verify  If true then can_checkin() is used to verify whether the person
1538
+	 *                      can be checked in or not.  Otherwise this forces change in checkin status.
1539
+	 * @return bool|int     the chk_in status toggled to OR false if nothing got changed.
1540
+	 * @throws EE_Error
1541
+	 */
1542
+	public function toggle_checkin_status($DTT_ID = null, $verify = false)
1543
+	{
1544
+		if (empty($DTT_ID)) {
1545
+			$datetime = $this->get_latest_related_datetime();
1546
+			$DTT_ID = $datetime instanceof EE_Datetime ? $datetime->ID() : 0;
1547
+			// verify the registration can checkin for the given DTT_ID
1548
+		} elseif (! $this->can_checkin($DTT_ID, $verify)) {
1549
+			EE_Error::add_error(
1550
+				sprintf(
1551
+					esc_html__(
1552
+						'The given registration (ID:%1$d) can not be checked in to the given DTT_ID (%2$d), because the registration does not have access',
1553
+						'event_espresso'
1554
+					),
1555
+					$this->ID(),
1556
+					$DTT_ID
1557
+				),
1558
+				__FILE__,
1559
+				__FUNCTION__,
1560
+				__LINE__
1561
+			);
1562
+			return false;
1563
+		}
1564
+		$status_paths = array(
1565
+			EE_Checkin::status_checked_never => EE_Checkin::status_checked_in,
1566
+			EE_Checkin::status_checked_in    => EE_Checkin::status_checked_out,
1567
+			EE_Checkin::status_checked_out   => EE_Checkin::status_checked_in,
1568
+		);
1569
+		// start by getting the current status so we know what status we'll be changing to.
1570
+		$cur_status = $this->check_in_status_for_datetime($DTT_ID);
1571
+		$status_to = $status_paths[ $cur_status ];
1572
+		// database only records true for checked IN or false for checked OUT
1573
+		// no record ( null ) means checked in NEVER, but we obviously don't save that
1574
+		$new_status = $status_to === EE_Checkin::status_checked_in ? true : false;
1575
+		// add relation - note Check-ins are always creating new rows
1576
+		// because we are keeping track of Check-ins over time.
1577
+		// Eventually we'll probably want to show a list table
1578
+		// for the individual Check-ins so that they can be managed.
1579
+		$checkin = EE_Checkin::new_instance(
1580
+			array(
1581
+				'REG_ID' => $this->ID(),
1582
+				'DTT_ID' => $DTT_ID,
1583
+				'CHK_in' => $new_status,
1584
+			)
1585
+		);
1586
+		// if the record could not be saved then return false
1587
+		if ($checkin->save() === 0) {
1588
+			if (WP_DEBUG) {
1589
+				global $wpdb;
1590
+				$error = sprintf(
1591
+					esc_html__(
1592
+						'Registration check in update failed because of the following database error: %1$s%2$s',
1593
+						'event_espresso'
1594
+					),
1595
+					'<br />',
1596
+					$wpdb->last_error
1597
+				);
1598
+			} else {
1599
+				$error = esc_html__(
1600
+					'Registration check in update failed because of an unknown database error',
1601
+					'event_espresso'
1602
+				);
1603
+			}
1604
+			EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
1605
+			return false;
1606
+		}
1607
+		// Fire a checked_in and checkout_out action.
1608
+		$checked_status = $status_to === EE_Checkin::status_checked_in ? 'checked_in' : 'checked_out';
1609
+		do_action("AHEE__EE_Registration__toggle_checkin_status__{$checked_status}", $this, $DTT_ID);
1610
+		return $status_to;
1611
+	}
1612
+
1613
+
1614
+	/**
1615
+	 * Returns the latest datetime related to this registration (via the ticket attached to the registration).
1616
+	 * "Latest" is defined by the `DTT_EVT_start` column.
1617
+	 *
1618
+	 * @return EE_Datetime|null
1619
+	 * @throws EE_Error
1620
+	 */
1621
+	public function get_latest_related_datetime()
1622
+	{
1623
+		return EEM_Datetime::instance()->get_one(
1624
+			array(
1625
+				array(
1626
+					'Ticket.Registration.REG_ID' => $this->ID(),
1627
+				),
1628
+				'order_by' => array('DTT_EVT_start' => 'DESC'),
1629
+			)
1630
+		);
1631
+	}
1632
+
1633
+
1634
+	/**
1635
+	 * Returns the earliest datetime related to this registration (via the ticket attached to the registration).
1636
+	 * "Earliest" is defined by the `DTT_EVT_start` column.
1637
+	 *
1638
+	 * @throws EE_Error
1639
+	 */
1640
+	public function get_earliest_related_datetime()
1641
+	{
1642
+		return EEM_Datetime::instance()->get_one(
1643
+			array(
1644
+				array(
1645
+					'Ticket.Registration.REG_ID' => $this->ID(),
1646
+				),
1647
+				'order_by' => array('DTT_EVT_start' => 'ASC'),
1648
+			)
1649
+		);
1650
+	}
1651
+
1652
+
1653
+	/**
1654
+	 * This method simply returns the check-in status for this registration and the given datetime.
1655
+	 * If neither the datetime nor the checkin values are provided as arguments,
1656
+	 * then this will return the LATEST check-in status for the registration across all datetimes it belongs to.
1657
+	 *
1658
+	 * @param int|null        $DTT_ID  The ID of the datetime we're checking against
1659
+	 *                                 (if empty we'll get the primary datetime for
1660
+	 *                                 this registration (via event) and use it's ID);
1661
+	 * @param EE_Checkin|null $checkin If present, we use the given checkin object rather than the dtt_id.
1662
+	 * @return int                     Integer representing Check-in status.
1663
+	 * @throws EE_Error
1664
+	 * @throws ReflectionException
1665
+	 */
1666
+	public function check_in_status_for_datetime(?int $DTT_ID = 0, ?EE_Checkin $checkin = null): int
1667
+	{
1668
+		if ($checkin instanceof EE_Checkin) {
1669
+			return $checkin->status();
1670
+		}
1671
+		// can't query checkin for a specific date if no ID was supplied
1672
+		if (empty($DTT_ID)) {
1673
+			return EE_Checkin::status_invalid;
1674
+		}
1675
+
1676
+		$checkin = $this->get_first_related(
1677
+			'Checkin',
1678
+			[
1679
+				['DTT_ID' => $DTT_ID],
1680
+				'order_by' => ['CHK_timestamp' => 'DESC'],
1681
+			]
1682
+		);
1683
+		return $checkin instanceof EE_Checkin ? $checkin->status():  EE_Checkin::status_checked_never;
1684
+	}
1685
+
1686
+
1687
+	/**
1688
+	 * This method returns a localized message for the toggled Check-in message.
1689
+	 *
1690
+	 * @param int|null $DTT_ID include specific datetime to get the correct Check-in message.  If not included or null,
1691
+	 *                         then it is assumed Check-in for primary datetime was toggled.
1692
+	 * @param bool     $error  This just flags that you want an error message returned. This is put in so that the error
1693
+	 *                         message can be customized with the attendee name.
1694
+	 * @return string internationalized message
1695
+	 * @throws EE_Error
1696
+	 * @throws ReflectionException
1697
+	 */
1698
+	public function get_checkin_msg(?int $DTT_ID, bool $error = false): string
1699
+	{
1700
+		// let's get the attendee first so we can include the name of the attendee
1701
+		$attendee = $this->get_first_related('Attendee');
1702
+		if ($attendee instanceof EE_Attendee) {
1703
+			if ($error) {
1704
+				return sprintf(
1705
+					esc_html__("%s's check-in status was not changed.", "event_espresso"),
1706
+					$attendee->full_name()
1707
+				);
1708
+			}
1709
+			$cur_status = $this->check_in_status_for_datetime($DTT_ID);
1710
+			// what is the status message going to be?
1711
+			switch ($cur_status) {
1712
+				case EE_Checkin::status_checked_never:
1713
+					return sprintf(
1714
+						esc_html__("%s has been removed from Check-in records", "event_espresso"),
1715
+						$attendee->full_name()
1716
+					);
1717
+				case EE_Checkin::status_checked_in:
1718
+					return sprintf(esc_html__('%s has been checked in', 'event_espresso'), $attendee->full_name());
1719
+				case EE_Checkin::status_checked_out:
1720
+					return sprintf(esc_html__('%s has been checked out', 'event_espresso'), $attendee->full_name());
1721
+			}
1722
+		}
1723
+		return esc_html__("The check-in status could not be determined.", "event_espresso");
1724
+	}
1725
+
1726
+
1727
+	/**
1728
+	 * Returns the related EE_Transaction to this registration
1729
+	 *
1730
+	 * @return EE_Transaction
1731
+	 * @throws EE_Error
1732
+	 * @throws EntityNotFoundException
1733
+	 * @throws ReflectionException
1734
+	 */
1735
+	public function transaction(): EE_Transaction
1736
+	{
1737
+		$transaction = $this->get_first_related('Transaction');
1738
+		if (! $transaction instanceof \EE_Transaction) {
1739
+			throw new EntityNotFoundException('Transaction ID', $this->transaction_ID());
1740
+		}
1741
+		return $transaction;
1742
+	}
1743
+
1744
+
1745
+	/**
1746
+	 *        get Registration Code
1747
+	 */
1748
+	public function reg_code()
1749
+	{
1750
+		return $this->get('REG_code');
1751
+	}
1752
+
1753
+
1754
+	/**
1755
+	 *        get Transaction ID
1756
+	 */
1757
+	public function transaction_ID()
1758
+	{
1759
+		return $this->get('TXN_ID');
1760
+	}
1761
+
1762
+
1763
+	/**
1764
+	 * @return int
1765
+	 * @throws EE_Error
1766
+	 */
1767
+	public function ticket_ID()
1768
+	{
1769
+		return $this->get('TKT_ID');
1770
+	}
1771
+
1772
+
1773
+	/**
1774
+	 *        Set Registration Code
1775
+	 *
1776
+	 * @access    public
1777
+	 * @param    string  $REG_code Registration Code
1778
+	 * @param    boolean $use_default
1779
+	 * @throws EE_Error
1780
+	 */
1781
+	public function set_reg_code($REG_code, $use_default = false)
1782
+	{
1783
+		if (empty($REG_code)) {
1784
+			EE_Error::add_error(
1785
+				esc_html__('REG_code can not be empty.', 'event_espresso'),
1786
+				__FILE__,
1787
+				__FUNCTION__,
1788
+				__LINE__
1789
+			);
1790
+			return;
1791
+		}
1792
+		if (! $this->reg_code()) {
1793
+			parent::set('REG_code', $REG_code, $use_default);
1794
+		} else {
1795
+			EE_Error::doing_it_wrong(
1796
+				__CLASS__ . '::' . __FUNCTION__,
1797
+				esc_html__('Can not change a registration REG_code once it has been set.', 'event_espresso'),
1798
+				'4.6.0'
1799
+			);
1800
+		}
1801
+	}
1802
+
1803
+
1804
+	/**
1805
+	 * Returns all other registrations in the same group as this registrant who have the same ticket option.
1806
+	 * Note, if you want to just get all registrations in the same transaction (group), use:
1807
+	 *    $registration->transaction()->registrations();
1808
+	 *
1809
+	 * @since 4.5.0
1810
+	 * @return EE_Registration[] or empty array if this isn't a group registration.
1811
+	 * @throws EE_Error
1812
+	 */
1813
+	public function get_all_other_registrations_in_group()
1814
+	{
1815
+		if ($this->group_size() < 2) {
1816
+			return array();
1817
+		}
1818
+
1819
+		$query[0] = array(
1820
+			'TXN_ID' => $this->transaction_ID(),
1821
+			'REG_ID' => array('!=', $this->ID()),
1822
+			'TKT_ID' => $this->ticket_ID(),
1823
+		);
1824
+		/** @var EE_Registration[] $registrations */
1825
+		$registrations = $this->get_model()->get_all($query);
1826
+		return $registrations;
1827
+	}
1828
+
1829
+	/**
1830
+	 * Return the link to the admin details for the object.
1831
+	 *
1832
+	 * @return string
1833
+	 * @throws EE_Error
1834
+	 */
1835
+	public function get_admin_details_link()
1836
+	{
1837
+		EE_Registry::instance()->load_helper('URL');
1838
+		return EEH_URL::add_query_args_and_nonce(
1839
+			array(
1840
+				'page'    => 'espresso_registrations',
1841
+				'action'  => 'view_registration',
1842
+				'_REG_ID' => $this->ID(),
1843
+			),
1844
+			admin_url('admin.php')
1845
+		);
1846
+	}
1847
+
1848
+	/**
1849
+	 * Returns the link to the editor for the object.  Sometimes this is the same as the details.
1850
+	 *
1851
+	 * @return string
1852
+	 * @throws EE_Error
1853
+	 */
1854
+	public function get_admin_edit_link()
1855
+	{
1856
+		return $this->get_admin_details_link();
1857
+	}
1858
+
1859
+	/**
1860
+	 * Returns the link to a settings page for the object.
1861
+	 *
1862
+	 * @return string
1863
+	 * @throws EE_Error
1864
+	 */
1865
+	public function get_admin_settings_link()
1866
+	{
1867
+		return $this->get_admin_details_link();
1868
+	}
1869
+
1870
+	/**
1871
+	 * Returns the link to the "overview" for the object (typically the "list table" view).
1872
+	 *
1873
+	 * @return string
1874
+	 */
1875
+	public function get_admin_overview_link()
1876
+	{
1877
+		EE_Registry::instance()->load_helper('URL');
1878
+		return EEH_URL::add_query_args_and_nonce(
1879
+			array(
1880
+				'page' => 'espresso_registrations',
1881
+			),
1882
+			admin_url('admin.php')
1883
+		);
1884
+	}
1885
+
1886
+
1887
+	/**
1888
+	 * @param array $query_params
1889
+	 *
1890
+	 * @return \EE_Registration[]
1891
+	 * @throws EE_Error
1892
+	 */
1893
+	public function payments($query_params = array())
1894
+	{
1895
+		return $this->get_many_related('Payment', $query_params);
1896
+	}
1897
+
1898
+
1899
+	/**
1900
+	 * @param array $query_params
1901
+	 *
1902
+	 * @return \EE_Registration_Payment[]
1903
+	 * @throws EE_Error
1904
+	 */
1905
+	public function registration_payments($query_params = array())
1906
+	{
1907
+		return $this->get_many_related('Registration_Payment', $query_params);
1908
+	}
1909
+
1910
+
1911
+	/**
1912
+	 * This grabs the payment method corresponding to the last payment made for the amount owing on the registration.
1913
+	 * Note: if there are no payments on the registration there will be no payment method returned.
1914
+	 *
1915
+	 * @return EE_Payment_Method|null
1916
+	 */
1917
+	public function payment_method()
1918
+	{
1919
+		return EEM_Payment_Method::instance()->get_last_used_for_registration($this);
1920
+	}
1921
+
1922
+
1923
+	/**
1924
+	 * @return \EE_Line_Item
1925
+	 * @throws EntityNotFoundException
1926
+	 * @throws EE_Error
1927
+	 */
1928
+	public function ticket_line_item()
1929
+	{
1930
+		$ticket = $this->ticket();
1931
+		$transaction = $this->transaction();
1932
+		$line_item = null;
1933
+		$ticket_line_items = \EEH_Line_Item::get_line_items_by_object_type_and_IDs(
1934
+			$transaction->total_line_item(),
1935
+			'Ticket',
1936
+			array($ticket->ID())
1937
+		);
1938
+		foreach ($ticket_line_items as $ticket_line_item) {
1939
+			if (
1940
+				$ticket_line_item instanceof \EE_Line_Item
1941
+				&& $ticket_line_item->OBJ_type() === 'Ticket'
1942
+				&& $ticket_line_item->OBJ_ID() === $ticket->ID()
1943
+			) {
1944
+				$line_item = $ticket_line_item;
1945
+				break;
1946
+			}
1947
+		}
1948
+		if (! ($line_item instanceof \EE_Line_Item && $line_item->OBJ_type() === 'Ticket')) {
1949
+			throw new EntityNotFoundException('Line Item Ticket ID', $ticket->ID());
1950
+		}
1951
+		return $line_item;
1952
+	}
1953
+
1954
+
1955
+	/**
1956
+	 * Soft Deletes this model object.
1957
+	 *
1958
+	 * @return boolean | int
1959
+	 * @throws RuntimeException
1960
+	 * @throws EE_Error
1961
+	 */
1962
+	public function delete()
1963
+	{
1964
+		if ($this->update_extra_meta(EE_Registration::PRE_TRASH_REG_STATUS_KEY, $this->status_ID()) === true) {
1965
+			$this->set_status(EEM_Registration::status_id_cancelled);
1966
+		}
1967
+		return parent::delete();
1968
+	}
1969
+
1970
+
1971
+	/**
1972
+	 * Restores whatever the previous status was on a registration before it was trashed (if possible)
1973
+	 *
1974
+	 * @throws EE_Error
1975
+	 * @throws RuntimeException
1976
+	 */
1977
+	public function restore()
1978
+	{
1979
+		$previous_status = $this->get_extra_meta(
1980
+			EE_Registration::PRE_TRASH_REG_STATUS_KEY,
1981
+			true,
1982
+			EEM_Registration::status_id_cancelled
1983
+		);
1984
+		if ($previous_status) {
1985
+			$this->delete_extra_meta(EE_Registration::PRE_TRASH_REG_STATUS_KEY);
1986
+			$this->set_status($previous_status);
1987
+		}
1988
+		return parent::restore();
1989
+	}
1990
+
1991
+
1992
+	/**
1993
+	 * possibly toggle Registration status based on comparison of REG_paid vs REG_final_price
1994
+	 *
1995
+	 * @param  boolean $trigger_set_status_logic EE_Registration::set_status() can trigger additional logic
1996
+	 *                                           depending on whether the reg status changes to or from "Approved"
1997
+	 * @return boolean whether the Registration status was updated
1998
+	 * @throws EE_Error
1999
+	 * @throws RuntimeException
2000
+	 */
2001
+	public function updateStatusBasedOnTotalPaid($trigger_set_status_logic = true)
2002
+	{
2003
+		$paid = $this->paid();
2004
+		$price = $this->final_price();
2005
+		switch (true) {
2006
+			// overpaid or paid
2007
+			case EEH_Money::compare_floats($paid, $price, '>'):
2008
+			case EEH_Money::compare_floats($paid, $price):
2009
+				$new_status = EEM_Registration::status_id_approved;
2010
+				break;
2011
+			//  underpaid
2012
+			case EEH_Money::compare_floats($paid, $price, '<'):
2013
+				$new_status = EEM_Registration::status_id_pending_payment;
2014
+				break;
2015
+			// uhhh Houston...
2016
+			default:
2017
+				throw new RuntimeException(
2018
+					esc_html__('The total paid calculation for this registration is inaccurate.', 'event_espresso')
2019
+				);
2020
+		}
2021
+		if ($new_status !== $this->status_ID()) {
2022
+			if ($trigger_set_status_logic) {
2023
+				return $this->set_status($new_status);
2024
+			}
2025
+			parent::set('STS_ID', $new_status);
2026
+			return true;
2027
+		}
2028
+		return false;
2029
+	}
2030
+
2031
+
2032
+	/*************************** DEPRECATED ***************************/
2033
+
2034
+
2035
+	/**
2036
+	 * @deprecated
2037
+	 * @since     4.7.0
2038
+	 * @access    public
2039
+	 */
2040
+	public function price_paid()
2041
+	{
2042
+		EE_Error::doing_it_wrong(
2043
+			'EE_Registration::price_paid()',
2044
+			esc_html__(
2045
+				'This method is deprecated, please use EE_Registration::final_price() instead.',
2046
+				'event_espresso'
2047
+			),
2048
+			'4.7.0'
2049
+		);
2050
+		return $this->final_price();
2051
+	}
2052
+
2053
+
2054
+	/**
2055
+	 * @deprecated
2056
+	 * @since     4.7.0
2057
+	 * @access    public
2058
+	 * @param    float $REG_final_price
2059
+	 * @throws EE_Error
2060
+	 * @throws RuntimeException
2061
+	 */
2062
+	public function set_price_paid($REG_final_price = 0.00)
2063
+	{
2064
+		EE_Error::doing_it_wrong(
2065
+			'EE_Registration::set_price_paid()',
2066
+			esc_html__(
2067
+				'This method is deprecated, please use EE_Registration::set_final_price() instead.',
2068
+				'event_espresso'
2069
+			),
2070
+			'4.7.0'
2071
+		);
2072
+		$this->set_final_price($REG_final_price);
2073
+	}
2074
+
2075
+
2076
+	/**
2077
+	 * @deprecated
2078
+	 * @since 4.7.0
2079
+	 * @return string
2080
+	 * @throws EE_Error
2081
+	 */
2082
+	public function pretty_price_paid()
2083
+	{
2084
+		EE_Error::doing_it_wrong(
2085
+			'EE_Registration::pretty_price_paid()',
2086
+			esc_html__(
2087
+				'This method is deprecated, please use EE_Registration::pretty_final_price() instead.',
2088
+				'event_espresso'
2089
+			),
2090
+			'4.7.0'
2091
+		);
2092
+		return $this->pretty_final_price();
2093
+	}
2094
+
2095
+
2096
+	/**
2097
+	 * Gets the primary datetime related to this registration via the related Event to this registration
2098
+	 *
2099
+	 * @deprecated 4.9.17
2100
+	 * @return EE_Datetime
2101
+	 * @throws EE_Error
2102
+	 * @throws EntityNotFoundException
2103
+	 */
2104
+	public function get_related_primary_datetime()
2105
+	{
2106
+		EE_Error::doing_it_wrong(
2107
+			__METHOD__,
2108
+			esc_html__(
2109
+				'Use EE_Registration::get_latest_related_datetime() or EE_Registration::get_earliest_related_datetime()',
2110
+				'event_espresso'
2111
+			),
2112
+			'4.9.17',
2113
+			'5.0.0'
2114
+		);
2115
+		return $this->event()->primary_datetime();
2116
+	}
2117
+
2118
+	/**
2119
+	 * Returns the contact's name (or "Unknown" if there is no contact.)
2120
+	 * @since 4.10.12.p
2121
+	 * @return string
2122
+	 * @throws EE_Error
2123
+	 * @throws InvalidArgumentException
2124
+	 * @throws InvalidDataTypeException
2125
+	 * @throws InvalidInterfaceException
2126
+	 * @throws ReflectionException
2127
+	 */
2128
+	public function name()
2129
+	{
2130
+		return $this->attendeeName();
2131
+	}
2132 2132
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
     {
120 120
         switch ($field_name) {
121 121
             case 'REG_code':
122
-                if (! empty($field_value) && $this->reg_code() === null) {
122
+                if ( ! empty($field_value) && $this->reg_code() === null) {
123 123
                     $this->set_reg_code($field_value, $use_default);
124 124
                 }
125 125
                 break;
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
     public function event()
407 407
     {
408 408
         $event = $this->get_first_related('Event');
409
-        if (! $event instanceof \EE_Event) {
409
+        if ( ! $event instanceof \EE_Event) {
410 410
             throw new EntityNotFoundException('Event ID', $this->event_ID());
411 411
         }
412 412
         return $event;
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
     {
450 450
         // reserved ticket and datetime counts will be decremented as sold counts are incremented
451 451
         // so stop tracking that this reg has a ticket reserved
452
-        $this->release_reserved_ticket(false, "REG: {$this->ID()} (ln:" . __LINE__ . ')');
452
+        $this->release_reserved_ticket(false, "REG: {$this->ID()} (ln:".__LINE__.')');
453 453
         $ticket = $this->ticket();
454 454
         $ticket->increaseSold();
455 455
         // possibly set event status to sold out
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
                 && $update_ticket
505 505
             ) {
506 506
                 $ticket = $this->ticket();
507
-                $ticket->increaseReserved(1, "REG: {$this->ID()} (ln:" . __LINE__ . ')');
507
+                $ticket->increaseReserved(1, "REG: {$this->ID()} (ln:".__LINE__.')');
508 508
                 $ticket->save();
509 509
             }
510 510
         }
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
                 && $update_ticket
537 537
             ) {
538 538
                 $ticket = $this->ticket();
539
-                $ticket->decreaseReserved(1, true, "REG: {$this->ID()} (ln:" . __LINE__ . ')');
539
+                $ticket->decreaseReserved(1, true, "REG: {$this->ID()} (ln:".__LINE__.')');
540 540
             }
541 541
         }
542 542
     }
@@ -1233,7 +1233,7 @@  discard block
 block discarded – undo
1233 1233
                     : '';
1234 1234
                 break;
1235 1235
         }
1236
-        return $icon . $status[ $this->status_ID() ];
1236
+        return $icon.$status[$this->status_ID()];
1237 1237
     }
1238 1238
 
1239 1239
 
@@ -1477,7 +1477,7 @@  discard block
 block discarded – undo
1477 1477
     {
1478 1478
         $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID);
1479 1479
 
1480
-        if (! $DTT_ID) {
1480
+        if ( ! $DTT_ID) {
1481 1481
             return false;
1482 1482
         }
1483 1483
 
@@ -1485,7 +1485,7 @@  discard block
 block discarded – undo
1485 1485
 
1486 1486
         // if max uses is not set or equals infinity then return true cause its not a factor for whether user can
1487 1487
         // check-in or not.
1488
-        if (! $max_uses || $max_uses === EE_INF) {
1488
+        if ( ! $max_uses || $max_uses === EE_INF) {
1489 1489
             return true;
1490 1490
         }
1491 1491
 
@@ -1545,7 +1545,7 @@  discard block
 block discarded – undo
1545 1545
             $datetime = $this->get_latest_related_datetime();
1546 1546
             $DTT_ID = $datetime instanceof EE_Datetime ? $datetime->ID() : 0;
1547 1547
             // verify the registration can checkin for the given DTT_ID
1548
-        } elseif (! $this->can_checkin($DTT_ID, $verify)) {
1548
+        } elseif ( ! $this->can_checkin($DTT_ID, $verify)) {
1549 1549
             EE_Error::add_error(
1550 1550
                 sprintf(
1551 1551
                     esc_html__(
@@ -1568,7 +1568,7 @@  discard block
 block discarded – undo
1568 1568
         );
1569 1569
         // start by getting the current status so we know what status we'll be changing to.
1570 1570
         $cur_status = $this->check_in_status_for_datetime($DTT_ID);
1571
-        $status_to = $status_paths[ $cur_status ];
1571
+        $status_to = $status_paths[$cur_status];
1572 1572
         // database only records true for checked IN or false for checked OUT
1573 1573
         // no record ( null ) means checked in NEVER, but we obviously don't save that
1574 1574
         $new_status = $status_to === EE_Checkin::status_checked_in ? true : false;
@@ -1680,7 +1680,7 @@  discard block
 block discarded – undo
1680 1680
                 'order_by' => ['CHK_timestamp' => 'DESC'],
1681 1681
             ]
1682 1682
         );
1683
-        return $checkin instanceof EE_Checkin ? $checkin->status():  EE_Checkin::status_checked_never;
1683
+        return $checkin instanceof EE_Checkin ? $checkin->status() : EE_Checkin::status_checked_never;
1684 1684
     }
1685 1685
 
1686 1686
 
@@ -1735,7 +1735,7 @@  discard block
 block discarded – undo
1735 1735
     public function transaction(): EE_Transaction
1736 1736
     {
1737 1737
         $transaction = $this->get_first_related('Transaction');
1738
-        if (! $transaction instanceof \EE_Transaction) {
1738
+        if ( ! $transaction instanceof \EE_Transaction) {
1739 1739
             throw new EntityNotFoundException('Transaction ID', $this->transaction_ID());
1740 1740
         }
1741 1741
         return $transaction;
@@ -1789,11 +1789,11 @@  discard block
 block discarded – undo
1789 1789
             );
1790 1790
             return;
1791 1791
         }
1792
-        if (! $this->reg_code()) {
1792
+        if ( ! $this->reg_code()) {
1793 1793
             parent::set('REG_code', $REG_code, $use_default);
1794 1794
         } else {
1795 1795
             EE_Error::doing_it_wrong(
1796
-                __CLASS__ . '::' . __FUNCTION__,
1796
+                __CLASS__.'::'.__FUNCTION__,
1797 1797
                 esc_html__('Can not change a registration REG_code once it has been set.', 'event_espresso'),
1798 1798
                 '4.6.0'
1799 1799
             );
@@ -1945,7 +1945,7 @@  discard block
 block discarded – undo
1945 1945
                 break;
1946 1946
             }
1947 1947
         }
1948
-        if (! ($line_item instanceof \EE_Line_Item && $line_item->OBJ_type() === 'Ticket')) {
1948
+        if ( ! ($line_item instanceof \EE_Line_Item && $line_item->OBJ_type() === 'Ticket')) {
1949 1949
             throw new EntityNotFoundException('Line Item Ticket ID', $ticket->ID());
1950 1950
         }
1951 1951
         return $line_item;
Please login to merge, or discard this patch.
core/helpers/EEH_Money.helper.php 2 patches
Indentation   +220 added lines, -220 removed lines patch added patch discarded remove patch
@@ -11,236 +11,236 @@
 block discarded – undo
11 11
 class EEH_Money extends EEH_Base
12 12
 {
13 13
 
14
-    /**
15
-     * This removes all localized money formatting from the incoming value
16
-     * Note: uses this site's currency settings for deciding what is considered a
17
-     * "thousands separator" (usually the character "," )
18
-     * and what is a "decimal mark" (usually the character ".")
19
-     *
20
-     * @param int|float|string $money_value
21
-     * @param string|null      $CNT_ISO
22
-     * @return float
23
-     * @throws EE_Error
24
-     * @throws ReflectionException
25
-     */
26
-    public static function strip_localized_money_formatting($money_value, ?string $CNT_ISO = ''): float
27
-    {
28
-        $currency_config = EE_Currency_Config::getCurrencyConfig($CNT_ISO);
29
-        $money_value     = str_replace(
30
-            [
31
-                $currency_config->thsnds,
32
-                $currency_config->dec_mrk,
33
-            ],
34
-            [
35
-                '', // remove thousands separator
36
-                '.', // convert decimal mark to what PHP expects
37
-            ],
38
-            $money_value
39
-        );
40
-        return (float) filter_var(
41
-            $money_value,
42
-            FILTER_SANITIZE_NUMBER_FLOAT,
43
-            FILTER_FLAG_ALLOW_FRACTION
44
-        );
45
-    }
14
+	/**
15
+	 * This removes all localized money formatting from the incoming value
16
+	 * Note: uses this site's currency settings for deciding what is considered a
17
+	 * "thousands separator" (usually the character "," )
18
+	 * and what is a "decimal mark" (usually the character ".")
19
+	 *
20
+	 * @param int|float|string $money_value
21
+	 * @param string|null      $CNT_ISO
22
+	 * @return float
23
+	 * @throws EE_Error
24
+	 * @throws ReflectionException
25
+	 */
26
+	public static function strip_localized_money_formatting($money_value, ?string $CNT_ISO = ''): float
27
+	{
28
+		$currency_config = EE_Currency_Config::getCurrencyConfig($CNT_ISO);
29
+		$money_value     = str_replace(
30
+			[
31
+				$currency_config->thsnds,
32
+				$currency_config->dec_mrk,
33
+			],
34
+			[
35
+				'', // remove thousands separator
36
+				'.', // convert decimal mark to what PHP expects
37
+			],
38
+			$money_value
39
+		);
40
+		return (float) filter_var(
41
+			$money_value,
42
+			FILTER_SANITIZE_NUMBER_FLOAT,
43
+			FILTER_FLAG_ALLOW_FRACTION
44
+		);
45
+	}
46 46
 
47 47
 
48
-    /**
49
-     * This converts an incoming localized money value into a standard float item (to three decimal places)
50
-     * Only use this if you know the $money_value follows your currency configuration's
51
-     * settings. Note: this uses this site's currency settings for deciding what is considered a
52
-     * "thousands separator" (usually the character "," )
53
-     * and what is a "decimal mark" (usually the character ".")
54
-     *
55
-     * @param int|float|string $money_value
56
-     * @return float
57
-     * @throws EE_Error
58
-     * @throws ReflectionException
59
-     */
60
-    public static function convert_to_float_from_localized_money($money_value): float
61
-    {
62
-        // float it! and round to three decimal places
63
-        return round(EEH_Money::strip_localized_money_formatting($money_value), 3);
64
-    }
48
+	/**
49
+	 * This converts an incoming localized money value into a standard float item (to three decimal places)
50
+	 * Only use this if you know the $money_value follows your currency configuration's
51
+	 * settings. Note: this uses this site's currency settings for deciding what is considered a
52
+	 * "thousands separator" (usually the character "," )
53
+	 * and what is a "decimal mark" (usually the character ".")
54
+	 *
55
+	 * @param int|float|string $money_value
56
+	 * @return float
57
+	 * @throws EE_Error
58
+	 * @throws ReflectionException
59
+	 */
60
+	public static function convert_to_float_from_localized_money($money_value): float
61
+	{
62
+		// float it! and round to three decimal places
63
+		return round(EEH_Money::strip_localized_money_formatting($money_value), 3);
64
+	}
65 65
 
66 66
 
67
-    /**
68
-     * For comparing floats. Default operator is '=', but see the $operator below for all options.
69
-     * This should be used to compare floats instead of normal '==' because floats
70
-     * are inherently imprecise, and so you can sometimes have two floats that appear to be identical
71
-     * but actually differ by 0.00000001.
72
-     *
73
-     * @see http://biostall.com/php-function-to-compare-floating-point-numbers
74
-     * @param int|float|string $float1
75
-     * @param int|float|string $float2
76
-     * @param string|null      $operator The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne
77
-     * @return bool whether the equation is true or false
78
-     * @throws EE_Error
79
-     */
80
-    public static function compare_floats($float1, $float2, ?string $operator = '='): bool
81
-    {
82
-        // Check numbers to 5 digits of precision
83
-        $epsilon = 0.00001;
84
-        $float1  = (float) $float1;
85
-        $float2  = (float) $float2;
86
-        switch ($operator) {
87
-            // equal
88
-            case '=':
89
-            case '==':
90
-            case '===':
91
-            case 'eq':
92
-                if (abs($float1 - $float2) < $epsilon) {
93
-                    return true;
94
-                }
95
-                break;
96
-            // less than
97
-            case '<':
98
-            case 'lt':
99
-                if (abs($float1 - $float2) < $epsilon) {
100
-                    return false;
101
-                }
102
-                if ($float1 < $float2) {
103
-                    return true;
104
-                }
105
-                break;
106
-            // less than or equal
107
-            case '<=':
108
-            case 'lte':
109
-                if (
110
-                    self::compare_floats($float1, $float2, '<')
111
-                    || self::compare_floats($float1, $float2)
112
-                ) {
113
-                    return true;
114
-                }
115
-                break;
116
-            // greater than
117
-            case '>':
118
-            case 'gt':
119
-                if (abs($float1 - $float2) < $epsilon) {
120
-                    return false;
121
-                }
122
-                if ($float1 > $float2) {
123
-                    return true;
124
-                }
125
-                break;
126
-            // greater than or equal
127
-            case '>=':
128
-            case 'gte':
129
-                if (
130
-                    self::compare_floats($float1, $float2, '>')
131
-                    || self::compare_floats($float1, $float2)
132
-                ) {
133
-                    return true;
134
-                }
135
-                break;
136
-            case '<>':
137
-            case '!=':
138
-            case '!==':
139
-            case 'ne':
140
-                if (abs($float1 - $float2) > $epsilon) {
141
-                    return true;
142
-                }
143
-                break;
144
-            default:
145
-                throw new EE_Error(
146
-                    sprintf(
147
-                        esc_html__(
148
-                            "Unknown operator %s in EEH_Money::compare_floats()",
149
-                            'event_espresso'
150
-                        ),
151
-                        $operator
152
-                    )
153
-                );
154
-        }
155
-        return false;
156
-    }
67
+	/**
68
+	 * For comparing floats. Default operator is '=', but see the $operator below for all options.
69
+	 * This should be used to compare floats instead of normal '==' because floats
70
+	 * are inherently imprecise, and so you can sometimes have two floats that appear to be identical
71
+	 * but actually differ by 0.00000001.
72
+	 *
73
+	 * @see http://biostall.com/php-function-to-compare-floating-point-numbers
74
+	 * @param int|float|string $float1
75
+	 * @param int|float|string $float2
76
+	 * @param string|null      $operator The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne
77
+	 * @return bool whether the equation is true or false
78
+	 * @throws EE_Error
79
+	 */
80
+	public static function compare_floats($float1, $float2, ?string $operator = '='): bool
81
+	{
82
+		// Check numbers to 5 digits of precision
83
+		$epsilon = 0.00001;
84
+		$float1  = (float) $float1;
85
+		$float2  = (float) $float2;
86
+		switch ($operator) {
87
+			// equal
88
+			case '=':
89
+			case '==':
90
+			case '===':
91
+			case 'eq':
92
+				if (abs($float1 - $float2) < $epsilon) {
93
+					return true;
94
+				}
95
+				break;
96
+			// less than
97
+			case '<':
98
+			case 'lt':
99
+				if (abs($float1 - $float2) < $epsilon) {
100
+					return false;
101
+				}
102
+				if ($float1 < $float2) {
103
+					return true;
104
+				}
105
+				break;
106
+			// less than or equal
107
+			case '<=':
108
+			case 'lte':
109
+				if (
110
+					self::compare_floats($float1, $float2, '<')
111
+					|| self::compare_floats($float1, $float2)
112
+				) {
113
+					return true;
114
+				}
115
+				break;
116
+			// greater than
117
+			case '>':
118
+			case 'gt':
119
+				if (abs($float1 - $float2) < $epsilon) {
120
+					return false;
121
+				}
122
+				if ($float1 > $float2) {
123
+					return true;
124
+				}
125
+				break;
126
+			// greater than or equal
127
+			case '>=':
128
+			case 'gte':
129
+				if (
130
+					self::compare_floats($float1, $float2, '>')
131
+					|| self::compare_floats($float1, $float2)
132
+				) {
133
+					return true;
134
+				}
135
+				break;
136
+			case '<>':
137
+			case '!=':
138
+			case '!==':
139
+			case 'ne':
140
+				if (abs($float1 - $float2) > $epsilon) {
141
+					return true;
142
+				}
143
+				break;
144
+			default:
145
+				throw new EE_Error(
146
+					sprintf(
147
+						esc_html__(
148
+							"Unknown operator %s in EEH_Money::compare_floats()",
149
+							'event_espresso'
150
+						),
151
+						$operator
152
+					)
153
+				);
154
+		}
155
+		return false;
156
+	}
157 157
 
158 158
 
159
-    /**
160
-     * This returns a localized format string suitable for jQplot.
161
-     *
162
-     * @param string|null $CNT_ISO If this is provided, then will attempt to get the currency settings for the country.
163
-     *                             Otherwise will use currency settings for current active country on site.
164
-     * @return string
165
-     * @throws EE_Error
166
-     * @throws ReflectionException
167
-     */
168
-    public static function get_format_for_jqplot(?string $CNT_ISO = ''): string
169
-    {
170
-        // default format
171
-        $format          = 'f';
172
-        $currency_config = EE_Currency_Config::getCurrencyConfig($CNT_ISO);
173
-        // first get the decimal place and number of places
174
-        $format = "%'." . $currency_config->dec_plc . $format;
175
-        // currency symbol on right side.
176
-        return $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign;
177
-    }
159
+	/**
160
+	 * This returns a localized format string suitable for jQplot.
161
+	 *
162
+	 * @param string|null $CNT_ISO If this is provided, then will attempt to get the currency settings for the country.
163
+	 *                             Otherwise will use currency settings for current active country on site.
164
+	 * @return string
165
+	 * @throws EE_Error
166
+	 * @throws ReflectionException
167
+	 */
168
+	public static function get_format_for_jqplot(?string $CNT_ISO = ''): string
169
+	{
170
+		// default format
171
+		$format          = 'f';
172
+		$currency_config = EE_Currency_Config::getCurrencyConfig($CNT_ISO);
173
+		// first get the decimal place and number of places
174
+		$format = "%'." . $currency_config->dec_plc . $format;
175
+		// currency symbol on right side.
176
+		return $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign;
177
+	}
178 178
 
179 179
 
180
-    /**
181
-     * This returns a localized format string suitable for usage with the Google Charts API format param.
182
-     *
183
-     * @param string|null $CNT_ISO If this is provided, then will attempt to get the currency settings for the country.
184
-     *                             Otherwise will use currency settings for current active country on site.
185
-     *                             Note: GoogleCharts uses ICU pattern set
186
-     *                             (@return array
187
-     * @return array
188
-     * @throws EE_Error
189
-     * @throws ReflectionException
190
-     * @see http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details)
191
-     */
192
-    public static function get_format_for_google_charts(?string $CNT_ISO = ''): array
193
-    {
194
-        $currency_config            = EE_Currency_Config::getCurrencyConfig($CNT_ISO);
195
-        $decimal_places_placeholder = str_pad('', $currency_config->dec_plc, '0');
196
-        // first get the decimal place and number of places
197
-        $format = '#,##0.' . $decimal_places_placeholder;
198
-        // currency symbol on right side.
199
-        $format          = $currency_config->sign_b4
200
-            ? $currency_config->sign . $format
201
-            : $format
202
-              . $currency_config->sign;
203
-        $formatterObject = [
204
-            'decimalSymbol'  => $currency_config->dec_mrk,
205
-            'groupingSymbol' => $currency_config->thsnds,
206
-            'fractionDigits' => $currency_config->dec_plc,
207
-        ];
208
-        if ($currency_config->sign_b4) {
209
-            $formatterObject['prefix'] = $currency_config->sign;
210
-        } else {
211
-            $formatterObject['suffix'] = $currency_config->sign;
212
-        }
213
-        return [
214
-            'format'          => $format,
215
-            'formatterObject' => $formatterObject,
216
-        ];
217
-    }
180
+	/**
181
+	 * This returns a localized format string suitable for usage with the Google Charts API format param.
182
+	 *
183
+	 * @param string|null $CNT_ISO If this is provided, then will attempt to get the currency settings for the country.
184
+	 *                             Otherwise will use currency settings for current active country on site.
185
+	 *                             Note: GoogleCharts uses ICU pattern set
186
+	 *                             (@return array
187
+	 * @return array
188
+	 * @throws EE_Error
189
+	 * @throws ReflectionException
190
+	 * @see http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details)
191
+	 */
192
+	public static function get_format_for_google_charts(?string $CNT_ISO = ''): array
193
+	{
194
+		$currency_config            = EE_Currency_Config::getCurrencyConfig($CNT_ISO);
195
+		$decimal_places_placeholder = str_pad('', $currency_config->dec_plc, '0');
196
+		// first get the decimal place and number of places
197
+		$format = '#,##0.' . $decimal_places_placeholder;
198
+		// currency symbol on right side.
199
+		$format          = $currency_config->sign_b4
200
+			? $currency_config->sign . $format
201
+			: $format
202
+			  . $currency_config->sign;
203
+		$formatterObject = [
204
+			'decimalSymbol'  => $currency_config->dec_mrk,
205
+			'groupingSymbol' => $currency_config->thsnds,
206
+			'fractionDigits' => $currency_config->dec_plc,
207
+		];
208
+		if ($currency_config->sign_b4) {
209
+			$formatterObject['prefix'] = $currency_config->sign;
210
+		} else {
211
+			$formatterObject['suffix'] = $currency_config->sign;
212
+		}
213
+		return [
214
+			'format'          => $format,
215
+			'formatterObject' => $formatterObject,
216
+		];
217
+	}
218 218
 
219 219
 
220
-    /**
221
-     * @param string|null $CNT_ISO
222
-     * @return EE_Currency_Config
223
-     * @throws EE_Error
224
-     * @throws ReflectionException
225
-     */
226
-    public static function get_currency_config(?string $CNT_ISO = ''): EE_Currency_Config
227
-    {
228
-        return EE_Currency_Config::getCurrencyConfig($CNT_ISO);
229
-    }
220
+	/**
221
+	 * @param string|null $CNT_ISO
222
+	 * @return EE_Currency_Config
223
+	 * @throws EE_Error
224
+	 * @throws ReflectionException
225
+	 */
226
+	public static function get_currency_config(?string $CNT_ISO = ''): EE_Currency_Config
227
+	{
228
+		return EE_Currency_Config::getCurrencyConfig($CNT_ISO);
229
+	}
230 230
 
231 231
 
232
-    /**
233
-     * @param string|null $CNT_ISO
234
-     * @param bool        $as_decimal if false [default] will return the number of decimal places ex: 1, 2, 3
235
-     *                                if true, will return the subunits as a decimal fraction ex: .1, .01, .001
236
-     * @return float
237
-     * @throws EE_Error
238
-     * @throws ReflectionException
239
-     * @since $VID:$
240
-     */
241
-    public static function getCurrencySubUnits(?string $CNT_ISO = '', bool $as_decimal = false): float
242
-    {
243
-        $currency_config = EE_Currency_Config::getCurrencyConfig($CNT_ISO);
244
-        return $as_decimal ? pow(10, ($currency_config->dec_plc * -1)) : $currency_config->dec_plc;
245
-    }
232
+	/**
233
+	 * @param string|null $CNT_ISO
234
+	 * @param bool        $as_decimal if false [default] will return the number of decimal places ex: 1, 2, 3
235
+	 *                                if true, will return the subunits as a decimal fraction ex: .1, .01, .001
236
+	 * @return float
237
+	 * @throws EE_Error
238
+	 * @throws ReflectionException
239
+	 * @since $VID:$
240
+	 */
241
+	public static function getCurrencySubUnits(?string $CNT_ISO = '', bool $as_decimal = false): float
242
+	{
243
+		$currency_config = EE_Currency_Config::getCurrencyConfig($CNT_ISO);
244
+		return $as_decimal ? pow(10, ($currency_config->dec_plc * -1)) : $currency_config->dec_plc;
245
+	}
246 246
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -171,9 +171,9 @@  discard block
 block discarded – undo
171 171
         $format          = 'f';
172 172
         $currency_config = EE_Currency_Config::getCurrencyConfig($CNT_ISO);
173 173
         // first get the decimal place and number of places
174
-        $format = "%'." . $currency_config->dec_plc . $format;
174
+        $format = "%'.".$currency_config->dec_plc.$format;
175 175
         // currency symbol on right side.
176
-        return $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign;
176
+        return $currency_config->sign_b4 ? $currency_config->sign.$format : $format.$currency_config->sign;
177 177
     }
178 178
 
179 179
 
@@ -194,10 +194,10 @@  discard block
 block discarded – undo
194 194
         $currency_config            = EE_Currency_Config::getCurrencyConfig($CNT_ISO);
195 195
         $decimal_places_placeholder = str_pad('', $currency_config->dec_plc, '0');
196 196
         // first get the decimal place and number of places
197
-        $format = '#,##0.' . $decimal_places_placeholder;
197
+        $format = '#,##0.'.$decimal_places_placeholder;
198 198
         // currency symbol on right side.
199
-        $format          = $currency_config->sign_b4
200
-            ? $currency_config->sign . $format
199
+        $format = $currency_config->sign_b4
200
+            ? $currency_config->sign.$format
201 201
             : $format
202 202
               . $currency_config->sign;
203 203
         $formatterObject = [
Please login to merge, or discard this patch.
core/EE_Dependency_Map.core.php 2 patches
Indentation   +1126 added lines, -1126 removed lines patch added patch discarded remove patch
@@ -21,1130 +21,1130 @@
 block discarded – undo
21 21
 class EE_Dependency_Map
22 22
 {
23 23
 
24
-    /**
25
-     * This means that the requested class dependency is not present in the dependency map
26
-     */
27
-    const not_registered = 0;
28
-
29
-    /**
30
-     * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
31
-     */
32
-    const load_new_object = 1;
33
-
34
-    /**
35
-     * This instructs class loaders to return a previously instantiated and cached object for the requested class.
36
-     * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
37
-     */
38
-    const load_from_cache = 2;
39
-
40
-    /**
41
-     * When registering a dependency,
42
-     * this indicates to keep any existing dependencies that already exist,
43
-     * and simply discard any new dependencies declared in the incoming data
44
-     */
45
-    const KEEP_EXISTING_DEPENDENCIES = 0;
46
-
47
-    /**
48
-     * When registering a dependency,
49
-     * this indicates to overwrite any existing dependencies that already exist using the incoming data
50
-     */
51
-    const OVERWRITE_DEPENDENCIES = 1;
52
-
53
-    /**
54
-     * @type EE_Dependency_Map $_instance
55
-     */
56
-    protected static $_instance;
57
-
58
-    /**
59
-     * @var ClassInterfaceCache $class_cache
60
-     */
61
-    private $class_cache;
62
-
63
-    /**
64
-     * @type RequestInterface $request
65
-     */
66
-    protected $request;
67
-
68
-    /**
69
-     * @type LegacyRequestInterface $legacy_request
70
-     */
71
-    protected $legacy_request;
72
-
73
-    /**
74
-     * @type ResponseInterface $response
75
-     */
76
-    protected $response;
77
-
78
-    /**
79
-     * @type LoaderInterface $loader
80
-     */
81
-    protected $loader;
82
-
83
-    /**
84
-     * @type array $_dependency_map
85
-     */
86
-    protected $_dependency_map = [];
87
-
88
-    /**
89
-     * @type array $_class_loaders
90
-     */
91
-    protected $_class_loaders = [];
92
-
93
-
94
-    /**
95
-     * EE_Dependency_Map constructor.
96
-     *
97
-     * @param ClassInterfaceCache $class_cache
98
-     */
99
-    protected function __construct(ClassInterfaceCache $class_cache)
100
-    {
101
-        $this->class_cache = $class_cache;
102
-        do_action('EE_Dependency_Map____construct', $this);
103
-    }
104
-
105
-
106
-    /**
107
-     * @return void
108
-     * @throws InvalidAliasException
109
-     */
110
-    public function initialize()
111
-    {
112
-        $this->_register_core_dependencies();
113
-        $this->_register_core_class_loaders();
114
-        $this->_register_core_aliases();
115
-    }
116
-
117
-
118
-    /**
119
-     * @singleton method used to instantiate class object
120
-     * @param ClassInterfaceCache|null $class_cache
121
-     * @return EE_Dependency_Map
122
-     */
123
-    public static function instance(ClassInterfaceCache $class_cache = null): EE_Dependency_Map
124
-    {
125
-        // check if class object is instantiated, and instantiated properly
126
-        if (
127
-            ! EE_Dependency_Map::$_instance instanceof EE_Dependency_Map
128
-            && $class_cache instanceof ClassInterfaceCache
129
-        ) {
130
-            EE_Dependency_Map::$_instance = new EE_Dependency_Map($class_cache);
131
-        }
132
-        return EE_Dependency_Map::$_instance;
133
-    }
134
-
135
-
136
-    /**
137
-     * @param RequestInterface $request
138
-     */
139
-    public function setRequest(RequestInterface $request)
140
-    {
141
-        $this->request = $request;
142
-    }
143
-
144
-
145
-    /**
146
-     * @param LegacyRequestInterface $legacy_request
147
-     */
148
-    public function setLegacyRequest(LegacyRequestInterface $legacy_request)
149
-    {
150
-        $this->legacy_request = $legacy_request;
151
-    }
152
-
153
-
154
-    /**
155
-     * @param ResponseInterface $response
156
-     */
157
-    public function setResponse(ResponseInterface $response)
158
-    {
159
-        $this->response = $response;
160
-    }
161
-
162
-
163
-    /**
164
-     * @param LoaderInterface $loader
165
-     */
166
-    public function setLoader(LoaderInterface $loader)
167
-    {
168
-        $this->loader = $loader;
169
-    }
170
-
171
-
172
-    /**
173
-     * @param string $class
174
-     * @param array  $dependencies
175
-     * @param int    $overwrite
176
-     * @return bool
177
-     */
178
-    public static function register_dependencies(
179
-        string $class,
180
-        array $dependencies,
181
-        int $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
182
-    ): bool {
183
-        return EE_Dependency_Map::$_instance->registerDependencies($class, $dependencies, $overwrite);
184
-    }
185
-
186
-
187
-    /**
188
-     * Assigns an array of class names and corresponding load sources (new or cached)
189
-     * to the class specified by the first parameter.
190
-     * IMPORTANT !!!
191
-     * The order of elements in the incoming $dependencies array MUST match
192
-     * the order of the constructor parameters for the class in question.
193
-     * This is especially important when overriding any existing dependencies that are registered.
194
-     * the third parameter controls whether any duplicate dependencies are overwritten or not.
195
-     *
196
-     * @param string $class
197
-     * @param array  $dependencies
198
-     * @param int    $overwrite
199
-     * @return bool
200
-     */
201
-    public function registerDependencies(
202
-        string $class,
203
-        array $dependencies,
204
-        int $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
205
-    ): bool {
206
-        $class      = trim($class, '\\');
207
-        $registered = false;
208
-        if (empty(EE_Dependency_Map::$_instance->_dependency_map[ $class ])) {
209
-            EE_Dependency_Map::$_instance->_dependency_map[ $class ] = [];
210
-        }
211
-        // we need to make sure that any aliases used when registering a dependency
212
-        // get resolved to the correct class name
213
-        foreach ($dependencies as $dependency => $load_source) {
214
-            $alias = EE_Dependency_Map::$_instance->getFqnForAlias($dependency);
215
-            if (
216
-                $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
217
-                || ! isset(EE_Dependency_Map::$_instance->_dependency_map[ $class ][ $alias ])
218
-            ) {
219
-                unset($dependencies[ $dependency ]);
220
-                $dependencies[ $alias ] = $load_source;
221
-                $registered             = true;
222
-            }
223
-        }
224
-        // now add our two lists of dependencies together.
225
-        // using Union (+=) favours the arrays in precedence from left to right,
226
-        // so $dependencies is NOT overwritten because it is listed first
227
-        // ie: with A = B + C, entries in B take precedence over duplicate entries in C
228
-        // Union is way faster than array_merge() but should be used with caution...
229
-        // especially with numerically indexed arrays
230
-        $dependencies += EE_Dependency_Map::$_instance->_dependency_map[ $class ];
231
-        // now we need to ensure that the resulting dependencies
232
-        // array only has the entries that are required for the class
233
-        // so first count how many dependencies were originally registered for the class
234
-        $dependency_count = count(EE_Dependency_Map::$_instance->_dependency_map[ $class ]);
235
-        // if that count is non-zero (meaning dependencies were already registered)
236
-        EE_Dependency_Map::$_instance->_dependency_map[ $class ] = $dependency_count
237
-            // then truncate the  final array to match that count
238
-            ? array_slice($dependencies, 0, $dependency_count)
239
-            // otherwise just take the incoming array because nothing previously existed
240
-            : $dependencies;
241
-        return $registered;
242
-    }
243
-
244
-
245
-    /**
246
-     * @param string          $class_name
247
-     * @param callable|string $loader
248
-     * @param bool            $overwrite
249
-     * @return bool
250
-     * @throws DomainException
251
-     */
252
-    public static function register_class_loader(
253
-        string $class_name,
254
-        $loader = 'load_core',
255
-        bool $overwrite = false
256
-    ): bool {
257
-        return EE_Dependency_Map::$_instance->registerClassLoader($class_name, $loader, $overwrite);
258
-    }
259
-
260
-
261
-    /**
262
-     * @param string $class_name
263
-     * @param Closure|string $loader
264
-     * @param bool   $overwrite
265
-     * @return bool
266
-     * @throws DomainException
267
-     */
268
-    public function registerClassLoader(string $class_name, $loader = 'load_core', bool $overwrite = false): bool
269
-    {
270
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
271
-            throw new DomainException(
272
-                esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
273
-            );
274
-        }
275
-        // check that loader is callable or method starts with "load_" and exists in EE_Registry
276
-        if (
277
-            ! is_callable($loader)
278
-            && (
279
-                strpos($loader, 'load_') !== 0
280
-                || ! method_exists('EE_Registry', $loader)
281
-            )
282
-        ) {
283
-            throw new DomainException(
284
-                sprintf(
285
-                    esc_html__(
286
-                        '"%1$s" is not a valid loader method on EE_Registry.',
287
-                        'event_espresso'
288
-                    ),
289
-                    $loader
290
-                )
291
-            );
292
-        }
293
-        $class_name = EE_Dependency_Map::$_instance->getFqnForAlias($class_name);
294
-        if ($overwrite || ! isset(EE_Dependency_Map::$_instance->_class_loaders[ $class_name ])) {
295
-            EE_Dependency_Map::$_instance->_class_loaders[ $class_name ] = $loader;
296
-            return true;
297
-        }
298
-        return false;
299
-    }
300
-
301
-
302
-    /**
303
-     * @return array
304
-     */
305
-    public function dependency_map(): array
306
-    {
307
-        return $this->_dependency_map;
308
-    }
309
-
310
-
311
-    /**
312
-     * returns TRUE if dependency map contains a listing for the provided class name
313
-     *
314
-     * @param string $class_name
315
-     * @return boolean
316
-     */
317
-    public function has(string $class_name = ''): bool
318
-    {
319
-        // all legacy models have the same dependencies
320
-        if (strpos($class_name, 'EEM_') === 0) {
321
-            $class_name = 'LEGACY_MODELS';
322
-        }
323
-        return isset($this->_dependency_map[ $class_name ]);
324
-    }
325
-
326
-
327
-    /**
328
-     * returns TRUE if dependency map contains a listing for the provided class name AND dependency
329
-     *
330
-     * @param string $class_name
331
-     * @param string $dependency
332
-     * @return bool
333
-     */
334
-    public function has_dependency_for_class(string $class_name = '', string $dependency = ''): bool
335
-    {
336
-        // all legacy models have the same dependencies
337
-        if (strpos($class_name, 'EEM_') === 0) {
338
-            $class_name = 'LEGACY_MODELS';
339
-        }
340
-        $dependency = $this->getFqnForAlias($dependency, $class_name);
341
-        return isset($this->_dependency_map[ $class_name ][ $dependency ]);
342
-    }
343
-
344
-
345
-    /**
346
-     * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
347
-     *
348
-     * @param string $class_name
349
-     * @param string $dependency
350
-     * @return int
351
-     */
352
-    public function loading_strategy_for_class_dependency(string $class_name = '', string $dependency = ''): int
353
-    {
354
-        // all legacy models have the same dependencies
355
-        if (strpos($class_name, 'EEM_') === 0) {
356
-            $class_name = 'LEGACY_MODELS';
357
-        }
358
-        $dependency = $this->getFqnForAlias($dependency);
359
-        return $this->has_dependency_for_class($class_name, $dependency)
360
-            ? $this->_dependency_map[ $class_name ][ $dependency ]
361
-            : EE_Dependency_Map::not_registered;
362
-    }
363
-
364
-
365
-    /**
366
-     * @param string $class_name
367
-     * @return string | Closure
368
-     */
369
-    public function class_loader(string $class_name)
370
-    {
371
-        // all legacy models use load_model()
372
-        if (strpos($class_name, 'EEM_') === 0) {
373
-            return 'load_model';
374
-        }
375
-        // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc
376
-        // perform strpos() first to avoid loading regex every time we load a class
377
-        if (
378
-            strpos($class_name, 'EE_CPT_') === 0
379
-            && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name)
380
-        ) {
381
-            return 'load_core';
382
-        }
383
-        $class_name = $this->getFqnForAlias($class_name);
384
-        return $this->_class_loaders[ $class_name ] ?? '';
385
-    }
386
-
387
-
388
-    /**
389
-     * @return array
390
-     */
391
-    public function class_loaders(): array
392
-    {
393
-        return $this->_class_loaders;
394
-    }
395
-
396
-
397
-    /**
398
-     * adds an alias for a classname
399
-     *
400
-     * @param string $fqcn      the class name that should be used (concrete class to replace interface)
401
-     * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
402
-     * @param string $for_class the class that has the dependency (is type hinting for the interface)
403
-     * @throws InvalidAliasException
404
-     */
405
-    public function add_alias(string $fqcn, string $alias, string $for_class = '')
406
-    {
407
-        $this->class_cache->addAlias($fqcn, $alias, $for_class);
408
-    }
409
-
410
-
411
-    /**
412
-     * Returns TRUE if the provided fully qualified name IS an alias
413
-     * WHY?
414
-     * Because if a class is type hinting for a concretion,
415
-     * then why would we need to find another class to supply it?
416
-     * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
417
-     * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
418
-     * Don't go looking for some substitute.
419
-     * Whereas if a class is type hinting for an interface...
420
-     * then we need to find an actual class to use.
421
-     * So the interface IS the alias for some other FQN,
422
-     * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
423
-     * represents some other class.
424
-     *
425
-     * @param string $fqn
426
-     * @param string $for_class
427
-     * @return bool
428
-     */
429
-    public function isAlias(string $fqn = '', string $for_class = ''): bool
430
-    {
431
-        return $this->class_cache->isAlias($fqn, $for_class);
432
-    }
433
-
434
-
435
-    /**
436
-     * Returns a FQN for provided alias if one exists, otherwise returns the original $alias
437
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
438
-     *  for example:
439
-     *      if the following two entries were added to the _aliases array:
440
-     *          array(
441
-     *              'interface_alias'           => 'some\namespace\interface'
442
-     *              'some\namespace\interface'  => 'some\namespace\classname'
443
-     *          )
444
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
445
-     *      to load an instance of 'some\namespace\classname'
446
-     *
447
-     * @param string $alias
448
-     * @param string $for_class
449
-     * @return string
450
-     */
451
-    public function getFqnForAlias(string $alias = '', string $for_class = ''): string
452
-    {
453
-        return $this->class_cache->getFqnForAlias($alias, $for_class);
454
-    }
455
-
456
-
457
-    /**
458
-     * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
459
-     * if one exists, or whether a new object should be generated every time the requested class is loaded.
460
-     * This is done by using the following class constants:
461
-     *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
462
-     *        EE_Dependency_Map::load_new_object - generates a new object every time
463
-     */
464
-    protected function _register_core_dependencies()
465
-    {
466
-        $this->_dependency_map = [
467
-            'EE_Admin'                                                                                                    => [
468
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
469
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
470
-            ],
471
-            'EE_Request_Handler'                                                                                          => [
472
-                'EventEspresso\core\services\request\Request'  => EE_Dependency_Map::load_from_cache,
473
-                'EventEspresso\core\services\request\Response' => EE_Dependency_Map::load_from_cache,
474
-            ],
475
-            'EE_System'                                                                                                   => [
476
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
477
-                'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
478
-                'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
479
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
480
-                'EventEspresso\core\services\routing\Router'  => EE_Dependency_Map::load_from_cache,
481
-            ],
482
-            'EE_Session'                                                                                                  => [
483
-                'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
484
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
485
-                'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
486
-                'EventEspresso\core\services\session\SessionStartHandler'  => EE_Dependency_Map::load_from_cache,
487
-                'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
488
-            ],
489
-            'EE_Cart'                                                                                                     => [
490
-                'EE_Session' => EE_Dependency_Map::load_from_cache,
491
-            ],
492
-            'EE_Messenger_Collection_Loader'                                                                              => [
493
-                'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
494
-            ],
495
-            'EE_Message_Type_Collection_Loader'                                                                           => [
496
-                'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
497
-            ],
498
-            'EE_Message_Resource_Manager'                                                                                 => [
499
-                'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
500
-                'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
501
-                'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
502
-            ],
503
-            'EE_Message_Factory'                                                                                          => [
504
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
505
-            ],
506
-            'EE_messages'                                                                                                 => [
507
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
508
-            ],
509
-            'EE_Messages_Generator'                                                                                       => [
510
-                'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
511
-                'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
512
-                'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
513
-                'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
514
-            ],
515
-            'EE_Messages_Processor'                                                                                       => [
516
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
517
-            ],
518
-            'EE_Messages_Queue'                                                                                           => [
519
-                'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
520
-            ],
521
-            'EE_Messages_Template_Defaults'                                                                               => [
522
-                'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
523
-                'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
524
-            ],
525
-            'EE_Message_To_Generate_From_Request'                                                                         => [
526
-                'EE_Message_Resource_Manager'                 => EE_Dependency_Map::load_from_cache,
527
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
528
-            ],
529
-            'EventEspresso\core\services\commands\CommandBus'                                                             => [
530
-                'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
531
-            ],
532
-            'EventEspresso\services\commands\CommandHandler'                                                              => [
533
-                'EE_Registry'         => EE_Dependency_Map::load_from_cache,
534
-                'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
535
-            ],
536
-            'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => [
537
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
538
-            ],
539
-            'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => [
540
-                'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
541
-                'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
542
-            ],
543
-            'EventEspresso\core\services\commands\CommandFactory'                                                         => [
544
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
545
-            ],
546
-            'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => [
547
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
548
-            ],
549
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => [
550
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
551
-            ],
552
-            'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => [
553
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
554
-            ],
555
-            'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => [
556
-                'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
557
-            ],
558
-            'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => [
559
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
560
-            ],
561
-            'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => [
562
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
563
-            ],
564
-            'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => [
565
-                'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
566
-            ],
567
-            'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => [
568
-                'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
569
-            ],
570
-            'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => [
571
-                'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
572
-            ],
573
-            'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => [
574
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
575
-            ],
576
-            'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => [
577
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
578
-            ],
579
-            'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => [
580
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
581
-            ],
582
-            'EventEspresso\core\services\database\TableManager'                                                           => [
583
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
584
-            ],
585
-            'EE_Data_Migration_Class_Base'                                                                                => [
586
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
587
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
588
-            ],
589
-            'EE_DMS_Core_4_1_0'                                                                                           => [
590
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
591
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
592
-            ],
593
-            'EE_DMS_Core_4_2_0'                                                                                           => [
594
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
595
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
596
-            ],
597
-            'EE_DMS_Core_4_3_0'                                                                                           => [
598
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
599
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
600
-            ],
601
-            'EE_DMS_Core_4_4_0'                                                                                           => [
602
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
603
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
604
-            ],
605
-            'EE_DMS_Core_4_5_0'                                                                                           => [
606
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
607
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
608
-            ],
609
-            'EE_DMS_Core_4_6_0'                                                                                           => [
610
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
611
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
612
-            ],
613
-            'EE_DMS_Core_4_7_0'                                                                                           => [
614
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
615
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
616
-            ],
617
-            'EE_DMS_Core_4_8_0'                                                                                           => [
618
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
619
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
620
-            ],
621
-            'EE_DMS_Core_4_9_0'                                                                                           => [
622
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
623
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
624
-            ],
625
-            'EE_DMS_Core_4_10_0'                                                                                          => [
626
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
627
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
628
-                'EE_DMS_Core_4_9_0'                                  => EE_Dependency_Map::load_from_cache,
629
-            ],
630
-            'EE_DMS_Core_4_11_0'                                                                                          => [
631
-                'EE_DMS_Core_4_10_0'                                 => EE_Dependency_Map::load_from_cache,
632
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
633
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
634
-            ],
635
-            'EE_DMS_Core_4_12_0'                                                                                          => [
636
-                'EE_DMS_Core_4_11_0'                                 => EE_Dependency_Map::load_from_cache,
637
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
638
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
639
-            ],
640
-            'EventEspresso\core\services\assets\I18nRegistry'                                                             => [
641
-                [],
642
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
643
-            ],
644
-            'EventEspresso\core\services\assets\Registry'                                                                 => [
645
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
646
-                'EventEspresso\core\services\assets\AssetManifest'   => EE_Dependency_Map::load_from_cache,
647
-            ],
648
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => [
649
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
650
-            ],
651
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => [
652
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
653
-            ],
654
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => [
655
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
656
-            ],
657
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => [
658
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
659
-            ],
660
-            'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => [
661
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
662
-            ],
663
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => [
664
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
665
-            ],
666
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => [
667
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
668
-            ],
669
-            'EventEspresso\core\services\cache\BasicCacheManager'                                                         => [
670
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
671
-            ],
672
-            'EventEspresso\core\services\cache\PostRelatedCacheManager'                                                   => [
673
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
674
-            ],
675
-            'EventEspresso\core\domain\services\validation\email\EmailValidationService'                                  => [
676
-                'EE_Registration_Config'                     => EE_Dependency_Map::load_from_cache,
677
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
678
-            ],
679
-            'EventEspresso\core\domain\values\EmailAddress'                                                               => [
680
-                null,
681
-                'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
682
-            ],
683
-            'EventEspresso\core\services\orm\ModelFieldFactory'                                                           => [
684
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
685
-            ],
686
-            'LEGACY_MODELS'                                                                                               => [
687
-                null,
688
-                'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
689
-            ],
690
-            'EE_Module_Request_Router'                                                                                    => [
691
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
692
-            ],
693
-            'EE_Registration_Processor'                                                                                   => [
694
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
695
-            ],
696
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'                                      => [
697
-                null,
698
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
699
-                'EventEspresso\core\services\request\Request'                         => EE_Dependency_Map::load_from_cache,
700
-            ],
701
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha'                                    => [
702
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
703
-                'EE_Session'             => EE_Dependency_Map::load_from_cache,
704
-            ],
705
-            'EventEspresso\modules\ticket_selector\DisplayTicketSelector'                                                 => [
706
-                'EventEspresso\core\domain\entities\users\CurrentUser' => EE_Dependency_Map::load_from_cache,
707
-                'EventEspresso\core\services\request\Request'          => EE_Dependency_Map::load_from_cache,
708
-                'EE_Ticket_Selector_Config'                            => EE_Dependency_Map::load_from_cache,
709
-            ],
710
-            'EventEspresso\modules\ticket_selector\ProcessTicketSelector'                                                 => [
711
-                'EE_Core_Config'                                                          => EE_Dependency_Map::load_from_cache,
712
-                'EventEspresso\core\services\request\Request'                             => EE_Dependency_Map::load_from_cache,
713
-                'EE_Session'                                                              => EE_Dependency_Map::load_from_cache,
714
-                'EEM_Ticket'                                                              => EE_Dependency_Map::load_from_cache,
715
-                'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
716
-            ],
717
-            'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'                                     => [
718
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
719
-            ],
720
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'                              => [
721
-                'EE_Core_Config'                             => EE_Dependency_Map::load_from_cache,
722
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
723
-            ],
724
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'                                => [
725
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
726
-            ],
727
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'                               => [
728
-                'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
729
-            ],
730
-            'EE_CPT_Strategy'                                                                                             => [
731
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
732
-                'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
733
-            ],
734
-            'EventEspresso\core\services\loaders\ObjectIdentifier'                                                        => [
735
-                'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
736
-            ],
737
-            'EventEspresso\core\CPTs\CptQueryModifier'                                                                    => [
738
-                null,
739
-                null,
740
-                null,
741
-                'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache,
742
-                'EventEspresso\core\services\request\Request'     => EE_Dependency_Map::load_from_cache,
743
-                'EventEspresso\core\services\loaders\Loader'      => EE_Dependency_Map::load_from_cache,
744
-            ],
745
-            'EventEspresso\core\services\dependencies\DependencyResolver'                                                 => [
746
-                'EventEspresso\core\services\container\Mirror'            => EE_Dependency_Map::load_from_cache,
747
-                'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
748
-                'EE_Dependency_Map'                                       => EE_Dependency_Map::load_from_cache,
749
-            ],
750
-            'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver'                               => [
751
-                'EventEspresso\core\services\container\Mirror'            => EE_Dependency_Map::load_from_cache,
752
-                'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
753
-                'EE_Dependency_Map'                                       => EE_Dependency_Map::load_from_cache,
754
-            ],
755
-            'EventEspresso\core\services\routing\RouteMatchSpecificationFactory'                                          => [
756
-                'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache,
757
-                'EventEspresso\core\services\loaders\Loader'                                    => EE_Dependency_Map::load_from_cache,
758
-            ],
759
-            'EventEspresso\core\services\routing\RouteMatchSpecificationManager'                                          => [
760
-                'EventEspresso\core\services\routing\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache,
761
-                'EventEspresso\core\services\routing\RouteMatchSpecificationFactory'    => EE_Dependency_Map::load_from_cache,
762
-            ],
763
-            'EE_URL_Validation_Strategy'                                                                                  => [
764
-                null,
765
-                null,
766
-                'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache,
767
-            ],
768
-            'EventEspresso\core\services\request\files\FilesDataHandler'                                                  => [
769
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
770
-            ],
771
-            'EventEspressoBatchRequest\BatchRequestProcessor'                                                             => [
772
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
773
-            ],
774
-            'EventEspresso\core\domain\services\converters\RestApiSpoofer'                                                => [
775
-                'WP_REST_Server'                                               => EE_Dependency_Map::load_from_cache,
776
-                'EED_Core_Rest_Api'                                            => EE_Dependency_Map::load_from_cache,
777
-                'EventEspresso\core\libraries\rest_api\controllers\model\Read' => EE_Dependency_Map::load_from_cache,
778
-                null,
779
-            ],
780
-            'EventEspresso\core\services\routing\RouteHandler'                                                            => [
781
-                'EventEspresso\core\services\json\JsonDataNodeHandler' => EE_Dependency_Map::load_from_cache,
782
-                'EventEspresso\core\services\loaders\Loader'           => EE_Dependency_Map::load_from_cache,
783
-                'EventEspresso\core\services\request\Request'          => EE_Dependency_Map::load_from_cache,
784
-                'EventEspresso\core\services\routing\RouteCollection'  => EE_Dependency_Map::load_from_cache,
785
-            ],
786
-            'EventEspresso\core\services\json\JsonDataNodeHandler'                                                        => [
787
-                'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache,
788
-            ],
789
-            'EventEspresso\core\services\routing\Router'                                                                  => [
790
-                'EE_Dependency_Map'                                => EE_Dependency_Map::load_from_cache,
791
-                'EventEspresso\core\services\loaders\Loader'       => EE_Dependency_Map::load_from_cache,
792
-                'EventEspresso\core\services\routing\RouteHandler' => EE_Dependency_Map::load_from_cache,
793
-            ],
794
-            'EventEspresso\core\services\assets\AssetManifest'                                                            => [
795
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
796
-            ],
797
-            'EventEspresso\core\services\assets\AssetManifestFactory'                                                     => [
798
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
799
-            ],
800
-            'EventEspresso\core\services\assets\BaristaFactory'                                                           => [
801
-                'EventEspresso\core\services\assets\AssetManifestFactory' => EE_Dependency_Map::load_from_cache,
802
-                'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
803
-            ],
804
-            'EventEspresso\core\domain\services\capabilities\FeatureFlags'                                                => [
805
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
806
-            ],
807
-            'EventEspresso\core\services\addon\AddonManager'                                                              => [
808
-                'EventEspresso\core\services\addon\AddonCollection'              => EE_Dependency_Map::load_from_cache,
809
-                'EventEspresso\core\Psr4Autoloader'                              => EE_Dependency_Map::load_from_cache,
810
-                'EventEspresso\core\services\addon\api\v1\RegisterAddon'         => EE_Dependency_Map::load_from_cache,
811
-                'EventEspresso\core\services\addon\api\IncompatibleAddonHandler' => EE_Dependency_Map::load_from_cache,
812
-                'EventEspresso\core\services\addon\api\ThirdPartyPluginHandler'  => EE_Dependency_Map::load_from_cache,
813
-            ],
814
-            'EventEspresso\core\services\addon\api\ThirdPartyPluginHandler'                                               => [
815
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
816
-            ],
817
-            'EventEspressoBatchRequest\JobHandlers\ExecuteBatchDeletion'                                                  => [
818
-                'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache,
819
-            ],
820
-            'EventEspressoBatchRequest\JobHandlers\PreviewEventDeletion'                                                  => [
821
-                'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache,
822
-            ],
823
-            'EventEspresso\core\domain\services\admin\events\data\PreviewDeletion'                                        => [
824
-                'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache,
825
-                'EEM_Event'                                                   => EE_Dependency_Map::load_from_cache,
826
-                'EEM_Datetime'                                                => EE_Dependency_Map::load_from_cache,
827
-                'EEM_Registration'                                            => EE_Dependency_Map::load_from_cache,
828
-            ],
829
-            'EventEspresso\core\domain\services\admin\events\data\ConfirmDeletion'                                        => [
830
-                'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache,
831
-            ],
832
-            'EventEspresso\core\services\request\CurrentPage'                                                             => [
833
-                'EE_CPT_Strategy'                             => EE_Dependency_Map::load_from_cache,
834
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
835
-            ],
836
-            'EventEspresso\core\services\shortcodes\LegacyShortcodesManager'                                              => [
837
-                'EE_Registry'                                     => EE_Dependency_Map::load_from_cache,
838
-                'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache,
839
-            ],
840
-            'EventEspresso\core\services\shortcodes\ShortcodesManager'                                                    => [
841
-                'EventEspresso\core\services\shortcodes\LegacyShortcodesManager' => EE_Dependency_Map::load_from_cache,
842
-                'EventEspresso\core\services\request\CurrentPage'                => EE_Dependency_Map::load_from_cache,
843
-            ],
844
-            'EventEspresso\core\domain\entities\users\CurrentUser'                                                        => [
845
-                'EventEspresso\core\domain\entities\users\EventManagers' => EE_Dependency_Map::load_from_cache,
846
-            ],
847
-            'EventEspresso\core\services\form\meta\InputTypes'                                                            => [
848
-                'EventEspresso\core\services\form\meta\inputs\Block'    => EE_Dependency_Map::load_from_cache,
849
-                'EventEspresso\core\services\form\meta\inputs\Button'   => EE_Dependency_Map::load_from_cache,
850
-                'EventEspresso\core\services\form\meta\inputs\DateTime' => EE_Dependency_Map::load_from_cache,
851
-                'EventEspresso\core\services\form\meta\inputs\Input'    => EE_Dependency_Map::load_from_cache,
852
-                'EventEspresso\core\services\form\meta\inputs\Number'   => EE_Dependency_Map::load_from_cache,
853
-                'EventEspresso\core\services\form\meta\inputs\Phone'    => EE_Dependency_Map::load_from_cache,
854
-                'EventEspresso\core\services\form\meta\inputs\Select'   => EE_Dependency_Map::load_from_cache,
855
-                'EventEspresso\core\services\form\meta\inputs\Text'     => EE_Dependency_Map::load_from_cache,
856
-            ],
857
-            'EventEspresso\core\domain\services\registration\form\v1\RegFormDependencyHandler'                            => [
858
-                'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache,
859
-            ],
860
-            'EventEspresso\core\services\calculators\LineItemCalculator'                                                  => [
861
-                'EventEspresso\core\services\helpers\DecimalValues' => EE_Dependency_Map::load_from_cache,
862
-            ],
863
-            'EventEspresso\core\services\helpers\DecimalValues'                                                           => [
864
-                'EE_Currency_Config' => EE_Dependency_Map::load_from_cache,
865
-            ],
866
-        ];
867
-    }
868
-
869
-
870
-    /**
871
-     * Registers how core classes are loaded.
872
-     * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
873
-     *        'EE_Request_Handler' => 'load_core'
874
-     *        'EE_Messages_Queue'  => 'load_lib'
875
-     *        'EEH_Debug_Tools'    => 'load_helper'
876
-     * or, if greater control is required, by providing a custom closure. For example:
877
-     *        'Some_Class' => function () {
878
-     *            return new Some_Class();
879
-     *        },
880
-     * This is required for instantiating dependencies
881
-     * where an interface has been type hinted in a class constructor. For example:
882
-     *        'Required_Interface' => function () {
883
-     *            return new A_Class_That_Implements_Required_Interface();
884
-     *        },
885
-     */
886
-    protected function _register_core_class_loaders()
887
-    {
888
-        $this->_class_loaders = [
889
-            // load_core
890
-            'EE_Dependency_Map'                            => function () {
891
-                return $this;
892
-            },
893
-            'EE_Capabilities'                              => 'load_core',
894
-            'EE_Encryption'                                => 'load_core',
895
-            'EE_Front_Controller'                          => 'load_core',
896
-            'EE_Module_Request_Router'                     => 'load_core',
897
-            'EE_Registry'                                  => 'load_core',
898
-            'EE_Request'                                   => function () {
899
-                return $this->legacy_request;
900
-            },
901
-            'EventEspresso\core\services\request\Request'  => function () {
902
-                return $this->request;
903
-            },
904
-            'EventEspresso\core\services\request\Response' => function () {
905
-                return $this->response;
906
-            },
907
-            'EE_Base'                                      => 'load_core',
908
-            'EE_Request_Handler'                           => 'load_core',
909
-            'EE_Session'                                   => 'load_core',
910
-            'EE_Cron_Tasks'                                => 'load_core',
911
-            'EE_System'                                    => 'load_core',
912
-            'EE_Maintenance_Mode'                          => 'load_core',
913
-            'EE_Register_CPTs'                             => 'load_core',
914
-            'EE_Admin'                                     => 'load_core',
915
-            'EE_CPT_Strategy'                              => 'load_core',
916
-            // load_class
917
-            'EE_Registration_Processor'                    => 'load_class',
918
-            // load_lib
919
-            'EE_Message_Resource_Manager'                  => 'load_lib',
920
-            'EE_Message_Type_Collection'                   => 'load_lib',
921
-            'EE_Message_Type_Collection_Loader'            => 'load_lib',
922
-            'EE_Messenger_Collection'                      => 'load_lib',
923
-            'EE_Messenger_Collection_Loader'               => 'load_lib',
924
-            'EE_Messages_Processor'                        => 'load_lib',
925
-            'EE_Message_Repository'                        => 'load_lib',
926
-            'EE_Messages_Queue'                            => 'load_lib',
927
-            'EE_Messages_Data_Handler_Collection'          => 'load_lib',
928
-            'EE_Message_Template_Group_Collection'         => 'load_lib',
929
-            'EE_Payment_Method_Manager'                    => 'load_lib',
930
-            'EE_DMS_Core_4_1_0'                            => 'load_dms',
931
-            'EE_DMS_Core_4_2_0'                            => 'load_dms',
932
-            'EE_DMS_Core_4_3_0'                            => 'load_dms',
933
-            'EE_DMS_Core_4_5_0'                            => 'load_dms',
934
-            'EE_DMS_Core_4_6_0'                            => 'load_dms',
935
-            'EE_DMS_Core_4_7_0'                            => 'load_dms',
936
-            'EE_DMS_Core_4_8_0'                            => 'load_dms',
937
-            'EE_DMS_Core_4_9_0'                            => 'load_dms',
938
-            'EE_DMS_Core_4_10_0'                           => 'load_dms',
939
-            'EE_DMS_Core_4_11_0'                           => 'load_dms',
940
-            'EE_DMS_Core_4_12_0'                           => 'load_dms',
941
-            'EE_Messages_Generator'                        => static function () {
942
-                return EE_Registry::instance()->load_lib(
943
-                    'Messages_Generator',
944
-                    [],
945
-                    false,
946
-                    false
947
-                );
948
-            },
949
-            'EE_Messages_Template_Defaults'                => static function ($arguments = []) {
950
-                return EE_Registry::instance()->load_lib(
951
-                    'Messages_Template_Defaults',
952
-                    $arguments,
953
-                    false,
954
-                    false
955
-                );
956
-            },
957
-            // load_helper
958
-            'EEH_Parse_Shortcodes'                         => static function () {
959
-                if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
960
-                    return new EEH_Parse_Shortcodes();
961
-                }
962
-                return null;
963
-            },
964
-            'EE_Template_Config'                           => static function () {
965
-                return EE_Config::instance()->template_settings;
966
-            },
967
-            'EE_Currency_Config'                           => static function () {
968
-                return EE_Currency_Config::getCurrencyConfig();
969
-            },
970
-            'EE_Registration_Config'                       => static function () {
971
-                return EE_Config::instance()->registration;
972
-            },
973
-            'EE_Core_Config'                               => static function () {
974
-                return EE_Config::instance()->core;
975
-            },
976
-            'EventEspresso\core\services\loaders\Loader'   => static function () {
977
-                return LoaderFactory::getLoader();
978
-            },
979
-            'EE_Network_Config'                            => static function () {
980
-                return EE_Network_Config::instance();
981
-            },
982
-            'EE_Config'                                    => static function () {
983
-                return EE_Config::instance();
984
-            },
985
-            'EventEspresso\core\domain\Domain'             => static function () {
986
-                return DomainFactory::getEventEspressoCoreDomain();
987
-            },
988
-            'EE_Admin_Config'                              => static function () {
989
-                return EE_Config::instance()->admin;
990
-            },
991
-            'EE_Organization_Config'                       => static function () {
992
-                return EE_Config::instance()->organization;
993
-            },
994
-            'EE_Network_Core_Config'                       => static function () {
995
-                return EE_Network_Config::instance()->core;
996
-            },
997
-            'EE_Environment_Config'                        => static function () {
998
-                return EE_Config::instance()->environment;
999
-            },
1000
-            'EED_Core_Rest_Api'                            => static function () {
1001
-                return EED_Core_Rest_Api::instance();
1002
-            },
1003
-            'WP_REST_Server'                               => static function () {
1004
-                return rest_get_server();
1005
-            },
1006
-            'EventEspresso\core\Psr4Autoloader'            => static function () {
1007
-                return EE_Psr4AutoloaderInit::psr4_loader();
1008
-            },
1009
-            'EE_Ticket_Selector_Config'                    => function () {
1010
-                return EE_Config::instance()->template_settings->EED_Ticket_Selector;
1011
-            },
1012
-        ];
1013
-    }
1014
-
1015
-
1016
-    /**
1017
-     * can be used for supplying alternate names for classes,
1018
-     * or for connecting interface names to instantiable classes
1019
-     *
1020
-     * @throws InvalidAliasException
1021
-     */
1022
-    protected function _register_core_aliases()
1023
-    {
1024
-        $aliases = [
1025
-            'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
1026
-            'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
1027
-            'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
1028
-            'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
1029
-            'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
1030
-            'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
1031
-            'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1032
-            'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
1033
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1034
-            'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
1035
-            'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
1036
-            'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
1037
-            'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
1038
-            'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
1039
-            'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
1040
-            'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
1041
-            'CreateTransactionCommandHandler'                                              => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
1042
-            'CreateAttendeeCommandHandler'                                                 => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
1043
-            'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
1044
-            'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
1045
-            'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1046
-            'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
1047
-            'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1048
-            'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
1049
-            'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
1050
-            'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
1051
-            'CommandFactoryInterface'                                                      => 'EventEspresso\core\services\commands\CommandFactoryInterface',
1052
-            'EventEspresso\core\services\commands\CommandFactoryInterface'                 => 'EventEspresso\core\services\commands\CommandFactory',
1053
-            'EmailValidatorInterface'                                                      => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
1054
-            'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface'  => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
1055
-            'NoticeConverterInterface'                                                     => 'EventEspresso\core\services\notices\NoticeConverterInterface',
1056
-            'EventEspresso\core\services\notices\NoticeConverterInterface'                 => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
1057
-            'NoticesContainerInterface'                                                    => 'EventEspresso\core\services\notices\NoticesContainerInterface',
1058
-            'EventEspresso\core\services\notices\NoticesContainerInterface'                => 'EventEspresso\core\services\notices\NoticesContainer',
1059
-            'EventEspresso\core\services\request\RequestInterface'                         => 'EventEspresso\core\services\request\Request',
1060
-            'EventEspresso\core\services\request\ResponseInterface'                        => 'EventEspresso\core\services\request\Response',
1061
-            'EventEspresso\core\domain\DomainInterface'                                    => 'EventEspresso\core\domain\Domain',
1062
-            'Registration_Processor'                                                       => 'EE_Registration_Processor',
1063
-            'EventEspresso\core\services\assets\AssetManifestInterface'                    => 'EventEspresso\core\services\assets\AssetManifest',
1064
-        ];
1065
-        foreach ($aliases as $alias => $fqn) {
1066
-            if (is_array($fqn)) {
1067
-                foreach ($fqn as $class => $for_class) {
1068
-                    $this->class_cache->addAlias($class, $alias, $for_class);
1069
-                }
1070
-                continue;
1071
-            }
1072
-            $this->class_cache->addAlias($fqn, $alias);
1073
-        }
1074
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
1075
-            $this->class_cache->addAlias(
1076
-                'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
1077
-                'EventEspresso\core\services\notices\NoticeConverterInterface'
1078
-            );
1079
-        }
1080
-    }
1081
-
1082
-
1083
-    public function debug($for_class = '')
1084
-    {
1085
-        if (method_exists($this->class_cache, 'debug')) {
1086
-            $this->class_cache->debug($for_class);
1087
-        }
1088
-    }
1089
-
1090
-
1091
-    /**
1092
-     * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
1093
-     * request Primarily used by unit tests.
1094
-     */
1095
-    public function reset()
1096
-    {
1097
-        $this->_register_core_class_loaders();
1098
-        $this->_register_core_dependencies();
1099
-    }
1100
-
1101
-
1102
-    /**
1103
-     * PLZ NOTE: a better name for this method would be is_alias()
1104
-     * because it returns TRUE if the provided fully qualified name IS an alias
1105
-     * WHY?
1106
-     * Because if a class is type hinting for a concretion,
1107
-     * then why would we need to find another class to supply it?
1108
-     * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
1109
-     * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
1110
-     * Don't go looking for some substitute.
1111
-     * Whereas if a class is type hinting for an interface...
1112
-     * then we need to find an actual class to use.
1113
-     * So the interface IS the alias for some other FQN,
1114
-     * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
1115
-     * represents some other class.
1116
-     *
1117
-     * @param string $fqn
1118
-     * @param string $for_class
1119
-     * @return bool
1120
-     * @deprecated 4.9.62.p
1121
-     */
1122
-    public function has_alias(string $fqn = '', string $for_class = ''): bool
1123
-    {
1124
-        return $this->isAlias($fqn, $for_class);
1125
-    }
1126
-
1127
-
1128
-    /**
1129
-     * PLZ NOTE: a better name for this method would be get_fqn_for_alias()
1130
-     * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias
1131
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
1132
-     *  for example:
1133
-     *      if the following two entries were added to the _aliases array:
1134
-     *          array(
1135
-     *              'interface_alias'           => 'some\namespace\interface'
1136
-     *              'some\namespace\interface'  => 'some\namespace\classname'
1137
-     *          )
1138
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
1139
-     *      to load an instance of 'some\namespace\classname'
1140
-     *
1141
-     * @param string $alias
1142
-     * @param string $for_class
1143
-     * @return string
1144
-     * @deprecated 4.9.62.p
1145
-     */
1146
-    public function get_alias(string $alias = '', string $for_class = ''): string
1147
-    {
1148
-        return $this->getFqnForAlias($alias, $for_class);
1149
-    }
24
+	/**
25
+	 * This means that the requested class dependency is not present in the dependency map
26
+	 */
27
+	const not_registered = 0;
28
+
29
+	/**
30
+	 * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
31
+	 */
32
+	const load_new_object = 1;
33
+
34
+	/**
35
+	 * This instructs class loaders to return a previously instantiated and cached object for the requested class.
36
+	 * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
37
+	 */
38
+	const load_from_cache = 2;
39
+
40
+	/**
41
+	 * When registering a dependency,
42
+	 * this indicates to keep any existing dependencies that already exist,
43
+	 * and simply discard any new dependencies declared in the incoming data
44
+	 */
45
+	const KEEP_EXISTING_DEPENDENCIES = 0;
46
+
47
+	/**
48
+	 * When registering a dependency,
49
+	 * this indicates to overwrite any existing dependencies that already exist using the incoming data
50
+	 */
51
+	const OVERWRITE_DEPENDENCIES = 1;
52
+
53
+	/**
54
+	 * @type EE_Dependency_Map $_instance
55
+	 */
56
+	protected static $_instance;
57
+
58
+	/**
59
+	 * @var ClassInterfaceCache $class_cache
60
+	 */
61
+	private $class_cache;
62
+
63
+	/**
64
+	 * @type RequestInterface $request
65
+	 */
66
+	protected $request;
67
+
68
+	/**
69
+	 * @type LegacyRequestInterface $legacy_request
70
+	 */
71
+	protected $legacy_request;
72
+
73
+	/**
74
+	 * @type ResponseInterface $response
75
+	 */
76
+	protected $response;
77
+
78
+	/**
79
+	 * @type LoaderInterface $loader
80
+	 */
81
+	protected $loader;
82
+
83
+	/**
84
+	 * @type array $_dependency_map
85
+	 */
86
+	protected $_dependency_map = [];
87
+
88
+	/**
89
+	 * @type array $_class_loaders
90
+	 */
91
+	protected $_class_loaders = [];
92
+
93
+
94
+	/**
95
+	 * EE_Dependency_Map constructor.
96
+	 *
97
+	 * @param ClassInterfaceCache $class_cache
98
+	 */
99
+	protected function __construct(ClassInterfaceCache $class_cache)
100
+	{
101
+		$this->class_cache = $class_cache;
102
+		do_action('EE_Dependency_Map____construct', $this);
103
+	}
104
+
105
+
106
+	/**
107
+	 * @return void
108
+	 * @throws InvalidAliasException
109
+	 */
110
+	public function initialize()
111
+	{
112
+		$this->_register_core_dependencies();
113
+		$this->_register_core_class_loaders();
114
+		$this->_register_core_aliases();
115
+	}
116
+
117
+
118
+	/**
119
+	 * @singleton method used to instantiate class object
120
+	 * @param ClassInterfaceCache|null $class_cache
121
+	 * @return EE_Dependency_Map
122
+	 */
123
+	public static function instance(ClassInterfaceCache $class_cache = null): EE_Dependency_Map
124
+	{
125
+		// check if class object is instantiated, and instantiated properly
126
+		if (
127
+			! EE_Dependency_Map::$_instance instanceof EE_Dependency_Map
128
+			&& $class_cache instanceof ClassInterfaceCache
129
+		) {
130
+			EE_Dependency_Map::$_instance = new EE_Dependency_Map($class_cache);
131
+		}
132
+		return EE_Dependency_Map::$_instance;
133
+	}
134
+
135
+
136
+	/**
137
+	 * @param RequestInterface $request
138
+	 */
139
+	public function setRequest(RequestInterface $request)
140
+	{
141
+		$this->request = $request;
142
+	}
143
+
144
+
145
+	/**
146
+	 * @param LegacyRequestInterface $legacy_request
147
+	 */
148
+	public function setLegacyRequest(LegacyRequestInterface $legacy_request)
149
+	{
150
+		$this->legacy_request = $legacy_request;
151
+	}
152
+
153
+
154
+	/**
155
+	 * @param ResponseInterface $response
156
+	 */
157
+	public function setResponse(ResponseInterface $response)
158
+	{
159
+		$this->response = $response;
160
+	}
161
+
162
+
163
+	/**
164
+	 * @param LoaderInterface $loader
165
+	 */
166
+	public function setLoader(LoaderInterface $loader)
167
+	{
168
+		$this->loader = $loader;
169
+	}
170
+
171
+
172
+	/**
173
+	 * @param string $class
174
+	 * @param array  $dependencies
175
+	 * @param int    $overwrite
176
+	 * @return bool
177
+	 */
178
+	public static function register_dependencies(
179
+		string $class,
180
+		array $dependencies,
181
+		int $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
182
+	): bool {
183
+		return EE_Dependency_Map::$_instance->registerDependencies($class, $dependencies, $overwrite);
184
+	}
185
+
186
+
187
+	/**
188
+	 * Assigns an array of class names and corresponding load sources (new or cached)
189
+	 * to the class specified by the first parameter.
190
+	 * IMPORTANT !!!
191
+	 * The order of elements in the incoming $dependencies array MUST match
192
+	 * the order of the constructor parameters for the class in question.
193
+	 * This is especially important when overriding any existing dependencies that are registered.
194
+	 * the third parameter controls whether any duplicate dependencies are overwritten or not.
195
+	 *
196
+	 * @param string $class
197
+	 * @param array  $dependencies
198
+	 * @param int    $overwrite
199
+	 * @return bool
200
+	 */
201
+	public function registerDependencies(
202
+		string $class,
203
+		array $dependencies,
204
+		int $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
205
+	): bool {
206
+		$class      = trim($class, '\\');
207
+		$registered = false;
208
+		if (empty(EE_Dependency_Map::$_instance->_dependency_map[ $class ])) {
209
+			EE_Dependency_Map::$_instance->_dependency_map[ $class ] = [];
210
+		}
211
+		// we need to make sure that any aliases used when registering a dependency
212
+		// get resolved to the correct class name
213
+		foreach ($dependencies as $dependency => $load_source) {
214
+			$alias = EE_Dependency_Map::$_instance->getFqnForAlias($dependency);
215
+			if (
216
+				$overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
217
+				|| ! isset(EE_Dependency_Map::$_instance->_dependency_map[ $class ][ $alias ])
218
+			) {
219
+				unset($dependencies[ $dependency ]);
220
+				$dependencies[ $alias ] = $load_source;
221
+				$registered             = true;
222
+			}
223
+		}
224
+		// now add our two lists of dependencies together.
225
+		// using Union (+=) favours the arrays in precedence from left to right,
226
+		// so $dependencies is NOT overwritten because it is listed first
227
+		// ie: with A = B + C, entries in B take precedence over duplicate entries in C
228
+		// Union is way faster than array_merge() but should be used with caution...
229
+		// especially with numerically indexed arrays
230
+		$dependencies += EE_Dependency_Map::$_instance->_dependency_map[ $class ];
231
+		// now we need to ensure that the resulting dependencies
232
+		// array only has the entries that are required for the class
233
+		// so first count how many dependencies were originally registered for the class
234
+		$dependency_count = count(EE_Dependency_Map::$_instance->_dependency_map[ $class ]);
235
+		// if that count is non-zero (meaning dependencies were already registered)
236
+		EE_Dependency_Map::$_instance->_dependency_map[ $class ] = $dependency_count
237
+			// then truncate the  final array to match that count
238
+			? array_slice($dependencies, 0, $dependency_count)
239
+			// otherwise just take the incoming array because nothing previously existed
240
+			: $dependencies;
241
+		return $registered;
242
+	}
243
+
244
+
245
+	/**
246
+	 * @param string          $class_name
247
+	 * @param callable|string $loader
248
+	 * @param bool            $overwrite
249
+	 * @return bool
250
+	 * @throws DomainException
251
+	 */
252
+	public static function register_class_loader(
253
+		string $class_name,
254
+		$loader = 'load_core',
255
+		bool $overwrite = false
256
+	): bool {
257
+		return EE_Dependency_Map::$_instance->registerClassLoader($class_name, $loader, $overwrite);
258
+	}
259
+
260
+
261
+	/**
262
+	 * @param string $class_name
263
+	 * @param Closure|string $loader
264
+	 * @param bool   $overwrite
265
+	 * @return bool
266
+	 * @throws DomainException
267
+	 */
268
+	public function registerClassLoader(string $class_name, $loader = 'load_core', bool $overwrite = false): bool
269
+	{
270
+		if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
271
+			throw new DomainException(
272
+				esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
273
+			);
274
+		}
275
+		// check that loader is callable or method starts with "load_" and exists in EE_Registry
276
+		if (
277
+			! is_callable($loader)
278
+			&& (
279
+				strpos($loader, 'load_') !== 0
280
+				|| ! method_exists('EE_Registry', $loader)
281
+			)
282
+		) {
283
+			throw new DomainException(
284
+				sprintf(
285
+					esc_html__(
286
+						'"%1$s" is not a valid loader method on EE_Registry.',
287
+						'event_espresso'
288
+					),
289
+					$loader
290
+				)
291
+			);
292
+		}
293
+		$class_name = EE_Dependency_Map::$_instance->getFqnForAlias($class_name);
294
+		if ($overwrite || ! isset(EE_Dependency_Map::$_instance->_class_loaders[ $class_name ])) {
295
+			EE_Dependency_Map::$_instance->_class_loaders[ $class_name ] = $loader;
296
+			return true;
297
+		}
298
+		return false;
299
+	}
300
+
301
+
302
+	/**
303
+	 * @return array
304
+	 */
305
+	public function dependency_map(): array
306
+	{
307
+		return $this->_dependency_map;
308
+	}
309
+
310
+
311
+	/**
312
+	 * returns TRUE if dependency map contains a listing for the provided class name
313
+	 *
314
+	 * @param string $class_name
315
+	 * @return boolean
316
+	 */
317
+	public function has(string $class_name = ''): bool
318
+	{
319
+		// all legacy models have the same dependencies
320
+		if (strpos($class_name, 'EEM_') === 0) {
321
+			$class_name = 'LEGACY_MODELS';
322
+		}
323
+		return isset($this->_dependency_map[ $class_name ]);
324
+	}
325
+
326
+
327
+	/**
328
+	 * returns TRUE if dependency map contains a listing for the provided class name AND dependency
329
+	 *
330
+	 * @param string $class_name
331
+	 * @param string $dependency
332
+	 * @return bool
333
+	 */
334
+	public function has_dependency_for_class(string $class_name = '', string $dependency = ''): bool
335
+	{
336
+		// all legacy models have the same dependencies
337
+		if (strpos($class_name, 'EEM_') === 0) {
338
+			$class_name = 'LEGACY_MODELS';
339
+		}
340
+		$dependency = $this->getFqnForAlias($dependency, $class_name);
341
+		return isset($this->_dependency_map[ $class_name ][ $dependency ]);
342
+	}
343
+
344
+
345
+	/**
346
+	 * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
347
+	 *
348
+	 * @param string $class_name
349
+	 * @param string $dependency
350
+	 * @return int
351
+	 */
352
+	public function loading_strategy_for_class_dependency(string $class_name = '', string $dependency = ''): int
353
+	{
354
+		// all legacy models have the same dependencies
355
+		if (strpos($class_name, 'EEM_') === 0) {
356
+			$class_name = 'LEGACY_MODELS';
357
+		}
358
+		$dependency = $this->getFqnForAlias($dependency);
359
+		return $this->has_dependency_for_class($class_name, $dependency)
360
+			? $this->_dependency_map[ $class_name ][ $dependency ]
361
+			: EE_Dependency_Map::not_registered;
362
+	}
363
+
364
+
365
+	/**
366
+	 * @param string $class_name
367
+	 * @return string | Closure
368
+	 */
369
+	public function class_loader(string $class_name)
370
+	{
371
+		// all legacy models use load_model()
372
+		if (strpos($class_name, 'EEM_') === 0) {
373
+			return 'load_model';
374
+		}
375
+		// EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc
376
+		// perform strpos() first to avoid loading regex every time we load a class
377
+		if (
378
+			strpos($class_name, 'EE_CPT_') === 0
379
+			&& preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name)
380
+		) {
381
+			return 'load_core';
382
+		}
383
+		$class_name = $this->getFqnForAlias($class_name);
384
+		return $this->_class_loaders[ $class_name ] ?? '';
385
+	}
386
+
387
+
388
+	/**
389
+	 * @return array
390
+	 */
391
+	public function class_loaders(): array
392
+	{
393
+		return $this->_class_loaders;
394
+	}
395
+
396
+
397
+	/**
398
+	 * adds an alias for a classname
399
+	 *
400
+	 * @param string $fqcn      the class name that should be used (concrete class to replace interface)
401
+	 * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
402
+	 * @param string $for_class the class that has the dependency (is type hinting for the interface)
403
+	 * @throws InvalidAliasException
404
+	 */
405
+	public function add_alias(string $fqcn, string $alias, string $for_class = '')
406
+	{
407
+		$this->class_cache->addAlias($fqcn, $alias, $for_class);
408
+	}
409
+
410
+
411
+	/**
412
+	 * Returns TRUE if the provided fully qualified name IS an alias
413
+	 * WHY?
414
+	 * Because if a class is type hinting for a concretion,
415
+	 * then why would we need to find another class to supply it?
416
+	 * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
417
+	 * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
418
+	 * Don't go looking for some substitute.
419
+	 * Whereas if a class is type hinting for an interface...
420
+	 * then we need to find an actual class to use.
421
+	 * So the interface IS the alias for some other FQN,
422
+	 * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
423
+	 * represents some other class.
424
+	 *
425
+	 * @param string $fqn
426
+	 * @param string $for_class
427
+	 * @return bool
428
+	 */
429
+	public function isAlias(string $fqn = '', string $for_class = ''): bool
430
+	{
431
+		return $this->class_cache->isAlias($fqn, $for_class);
432
+	}
433
+
434
+
435
+	/**
436
+	 * Returns a FQN for provided alias if one exists, otherwise returns the original $alias
437
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
438
+	 *  for example:
439
+	 *      if the following two entries were added to the _aliases array:
440
+	 *          array(
441
+	 *              'interface_alias'           => 'some\namespace\interface'
442
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
443
+	 *          )
444
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
445
+	 *      to load an instance of 'some\namespace\classname'
446
+	 *
447
+	 * @param string $alias
448
+	 * @param string $for_class
449
+	 * @return string
450
+	 */
451
+	public function getFqnForAlias(string $alias = '', string $for_class = ''): string
452
+	{
453
+		return $this->class_cache->getFqnForAlias($alias, $for_class);
454
+	}
455
+
456
+
457
+	/**
458
+	 * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
459
+	 * if one exists, or whether a new object should be generated every time the requested class is loaded.
460
+	 * This is done by using the following class constants:
461
+	 *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
462
+	 *        EE_Dependency_Map::load_new_object - generates a new object every time
463
+	 */
464
+	protected function _register_core_dependencies()
465
+	{
466
+		$this->_dependency_map = [
467
+			'EE_Admin'                                                                                                    => [
468
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
469
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
470
+			],
471
+			'EE_Request_Handler'                                                                                          => [
472
+				'EventEspresso\core\services\request\Request'  => EE_Dependency_Map::load_from_cache,
473
+				'EventEspresso\core\services\request\Response' => EE_Dependency_Map::load_from_cache,
474
+			],
475
+			'EE_System'                                                                                                   => [
476
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
477
+				'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
478
+				'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
479
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
480
+				'EventEspresso\core\services\routing\Router'  => EE_Dependency_Map::load_from_cache,
481
+			],
482
+			'EE_Session'                                                                                                  => [
483
+				'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
484
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
485
+				'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
486
+				'EventEspresso\core\services\session\SessionStartHandler'  => EE_Dependency_Map::load_from_cache,
487
+				'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
488
+			],
489
+			'EE_Cart'                                                                                                     => [
490
+				'EE_Session' => EE_Dependency_Map::load_from_cache,
491
+			],
492
+			'EE_Messenger_Collection_Loader'                                                                              => [
493
+				'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
494
+			],
495
+			'EE_Message_Type_Collection_Loader'                                                                           => [
496
+				'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
497
+			],
498
+			'EE_Message_Resource_Manager'                                                                                 => [
499
+				'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
500
+				'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
501
+				'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
502
+			],
503
+			'EE_Message_Factory'                                                                                          => [
504
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
505
+			],
506
+			'EE_messages'                                                                                                 => [
507
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
508
+			],
509
+			'EE_Messages_Generator'                                                                                       => [
510
+				'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
511
+				'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
512
+				'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
513
+				'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
514
+			],
515
+			'EE_Messages_Processor'                                                                                       => [
516
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
517
+			],
518
+			'EE_Messages_Queue'                                                                                           => [
519
+				'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
520
+			],
521
+			'EE_Messages_Template_Defaults'                                                                               => [
522
+				'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
523
+				'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
524
+			],
525
+			'EE_Message_To_Generate_From_Request'                                                                         => [
526
+				'EE_Message_Resource_Manager'                 => EE_Dependency_Map::load_from_cache,
527
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
528
+			],
529
+			'EventEspresso\core\services\commands\CommandBus'                                                             => [
530
+				'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
531
+			],
532
+			'EventEspresso\services\commands\CommandHandler'                                                              => [
533
+				'EE_Registry'         => EE_Dependency_Map::load_from_cache,
534
+				'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
535
+			],
536
+			'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => [
537
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
538
+			],
539
+			'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => [
540
+				'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
541
+				'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
542
+			],
543
+			'EventEspresso\core\services\commands\CommandFactory'                                                         => [
544
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
545
+			],
546
+			'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => [
547
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
548
+			],
549
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => [
550
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
551
+			],
552
+			'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => [
553
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
554
+			],
555
+			'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => [
556
+				'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
557
+			],
558
+			'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => [
559
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
560
+			],
561
+			'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => [
562
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
563
+			],
564
+			'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => [
565
+				'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
566
+			],
567
+			'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => [
568
+				'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
569
+			],
570
+			'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => [
571
+				'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
572
+			],
573
+			'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => [
574
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
575
+			],
576
+			'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => [
577
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
578
+			],
579
+			'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => [
580
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
581
+			],
582
+			'EventEspresso\core\services\database\TableManager'                                                           => [
583
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
584
+			],
585
+			'EE_Data_Migration_Class_Base'                                                                                => [
586
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
587
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
588
+			],
589
+			'EE_DMS_Core_4_1_0'                                                                                           => [
590
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
591
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
592
+			],
593
+			'EE_DMS_Core_4_2_0'                                                                                           => [
594
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
595
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
596
+			],
597
+			'EE_DMS_Core_4_3_0'                                                                                           => [
598
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
599
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
600
+			],
601
+			'EE_DMS_Core_4_4_0'                                                                                           => [
602
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
603
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
604
+			],
605
+			'EE_DMS_Core_4_5_0'                                                                                           => [
606
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
607
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
608
+			],
609
+			'EE_DMS_Core_4_6_0'                                                                                           => [
610
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
611
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
612
+			],
613
+			'EE_DMS_Core_4_7_0'                                                                                           => [
614
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
615
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
616
+			],
617
+			'EE_DMS_Core_4_8_0'                                                                                           => [
618
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
619
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
620
+			],
621
+			'EE_DMS_Core_4_9_0'                                                                                           => [
622
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
623
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
624
+			],
625
+			'EE_DMS_Core_4_10_0'                                                                                          => [
626
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
627
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
628
+				'EE_DMS_Core_4_9_0'                                  => EE_Dependency_Map::load_from_cache,
629
+			],
630
+			'EE_DMS_Core_4_11_0'                                                                                          => [
631
+				'EE_DMS_Core_4_10_0'                                 => EE_Dependency_Map::load_from_cache,
632
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
633
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
634
+			],
635
+			'EE_DMS_Core_4_12_0'                                                                                          => [
636
+				'EE_DMS_Core_4_11_0'                                 => EE_Dependency_Map::load_from_cache,
637
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
638
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
639
+			],
640
+			'EventEspresso\core\services\assets\I18nRegistry'                                                             => [
641
+				[],
642
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
643
+			],
644
+			'EventEspresso\core\services\assets\Registry'                                                                 => [
645
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
646
+				'EventEspresso\core\services\assets\AssetManifest'   => EE_Dependency_Map::load_from_cache,
647
+			],
648
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => [
649
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
650
+			],
651
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => [
652
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
653
+			],
654
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => [
655
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
656
+			],
657
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => [
658
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
659
+			],
660
+			'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => [
661
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
662
+			],
663
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => [
664
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
665
+			],
666
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => [
667
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
668
+			],
669
+			'EventEspresso\core\services\cache\BasicCacheManager'                                                         => [
670
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
671
+			],
672
+			'EventEspresso\core\services\cache\PostRelatedCacheManager'                                                   => [
673
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
674
+			],
675
+			'EventEspresso\core\domain\services\validation\email\EmailValidationService'                                  => [
676
+				'EE_Registration_Config'                     => EE_Dependency_Map::load_from_cache,
677
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
678
+			],
679
+			'EventEspresso\core\domain\values\EmailAddress'                                                               => [
680
+				null,
681
+				'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
682
+			],
683
+			'EventEspresso\core\services\orm\ModelFieldFactory'                                                           => [
684
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
685
+			],
686
+			'LEGACY_MODELS'                                                                                               => [
687
+				null,
688
+				'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
689
+			],
690
+			'EE_Module_Request_Router'                                                                                    => [
691
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
692
+			],
693
+			'EE_Registration_Processor'                                                                                   => [
694
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
695
+			],
696
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'                                      => [
697
+				null,
698
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
699
+				'EventEspresso\core\services\request\Request'                         => EE_Dependency_Map::load_from_cache,
700
+			],
701
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha'                                    => [
702
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
703
+				'EE_Session'             => EE_Dependency_Map::load_from_cache,
704
+			],
705
+			'EventEspresso\modules\ticket_selector\DisplayTicketSelector'                                                 => [
706
+				'EventEspresso\core\domain\entities\users\CurrentUser' => EE_Dependency_Map::load_from_cache,
707
+				'EventEspresso\core\services\request\Request'          => EE_Dependency_Map::load_from_cache,
708
+				'EE_Ticket_Selector_Config'                            => EE_Dependency_Map::load_from_cache,
709
+			],
710
+			'EventEspresso\modules\ticket_selector\ProcessTicketSelector'                                                 => [
711
+				'EE_Core_Config'                                                          => EE_Dependency_Map::load_from_cache,
712
+				'EventEspresso\core\services\request\Request'                             => EE_Dependency_Map::load_from_cache,
713
+				'EE_Session'                                                              => EE_Dependency_Map::load_from_cache,
714
+				'EEM_Ticket'                                                              => EE_Dependency_Map::load_from_cache,
715
+				'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
716
+			],
717
+			'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'                                     => [
718
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
719
+			],
720
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'                              => [
721
+				'EE_Core_Config'                             => EE_Dependency_Map::load_from_cache,
722
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
723
+			],
724
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'                                => [
725
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
726
+			],
727
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'                               => [
728
+				'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
729
+			],
730
+			'EE_CPT_Strategy'                                                                                             => [
731
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
732
+				'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
733
+			],
734
+			'EventEspresso\core\services\loaders\ObjectIdentifier'                                                        => [
735
+				'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
736
+			],
737
+			'EventEspresso\core\CPTs\CptQueryModifier'                                                                    => [
738
+				null,
739
+				null,
740
+				null,
741
+				'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache,
742
+				'EventEspresso\core\services\request\Request'     => EE_Dependency_Map::load_from_cache,
743
+				'EventEspresso\core\services\loaders\Loader'      => EE_Dependency_Map::load_from_cache,
744
+			],
745
+			'EventEspresso\core\services\dependencies\DependencyResolver'                                                 => [
746
+				'EventEspresso\core\services\container\Mirror'            => EE_Dependency_Map::load_from_cache,
747
+				'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
748
+				'EE_Dependency_Map'                                       => EE_Dependency_Map::load_from_cache,
749
+			],
750
+			'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver'                               => [
751
+				'EventEspresso\core\services\container\Mirror'            => EE_Dependency_Map::load_from_cache,
752
+				'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
753
+				'EE_Dependency_Map'                                       => EE_Dependency_Map::load_from_cache,
754
+			],
755
+			'EventEspresso\core\services\routing\RouteMatchSpecificationFactory'                                          => [
756
+				'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache,
757
+				'EventEspresso\core\services\loaders\Loader'                                    => EE_Dependency_Map::load_from_cache,
758
+			],
759
+			'EventEspresso\core\services\routing\RouteMatchSpecificationManager'                                          => [
760
+				'EventEspresso\core\services\routing\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache,
761
+				'EventEspresso\core\services\routing\RouteMatchSpecificationFactory'    => EE_Dependency_Map::load_from_cache,
762
+			],
763
+			'EE_URL_Validation_Strategy'                                                                                  => [
764
+				null,
765
+				null,
766
+				'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache,
767
+			],
768
+			'EventEspresso\core\services\request\files\FilesDataHandler'                                                  => [
769
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
770
+			],
771
+			'EventEspressoBatchRequest\BatchRequestProcessor'                                                             => [
772
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
773
+			],
774
+			'EventEspresso\core\domain\services\converters\RestApiSpoofer'                                                => [
775
+				'WP_REST_Server'                                               => EE_Dependency_Map::load_from_cache,
776
+				'EED_Core_Rest_Api'                                            => EE_Dependency_Map::load_from_cache,
777
+				'EventEspresso\core\libraries\rest_api\controllers\model\Read' => EE_Dependency_Map::load_from_cache,
778
+				null,
779
+			],
780
+			'EventEspresso\core\services\routing\RouteHandler'                                                            => [
781
+				'EventEspresso\core\services\json\JsonDataNodeHandler' => EE_Dependency_Map::load_from_cache,
782
+				'EventEspresso\core\services\loaders\Loader'           => EE_Dependency_Map::load_from_cache,
783
+				'EventEspresso\core\services\request\Request'          => EE_Dependency_Map::load_from_cache,
784
+				'EventEspresso\core\services\routing\RouteCollection'  => EE_Dependency_Map::load_from_cache,
785
+			],
786
+			'EventEspresso\core\services\json\JsonDataNodeHandler'                                                        => [
787
+				'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache,
788
+			],
789
+			'EventEspresso\core\services\routing\Router'                                                                  => [
790
+				'EE_Dependency_Map'                                => EE_Dependency_Map::load_from_cache,
791
+				'EventEspresso\core\services\loaders\Loader'       => EE_Dependency_Map::load_from_cache,
792
+				'EventEspresso\core\services\routing\RouteHandler' => EE_Dependency_Map::load_from_cache,
793
+			],
794
+			'EventEspresso\core\services\assets\AssetManifest'                                                            => [
795
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
796
+			],
797
+			'EventEspresso\core\services\assets\AssetManifestFactory'                                                     => [
798
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
799
+			],
800
+			'EventEspresso\core\services\assets\BaristaFactory'                                                           => [
801
+				'EventEspresso\core\services\assets\AssetManifestFactory' => EE_Dependency_Map::load_from_cache,
802
+				'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
803
+			],
804
+			'EventEspresso\core\domain\services\capabilities\FeatureFlags'                                                => [
805
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
806
+			],
807
+			'EventEspresso\core\services\addon\AddonManager'                                                              => [
808
+				'EventEspresso\core\services\addon\AddonCollection'              => EE_Dependency_Map::load_from_cache,
809
+				'EventEspresso\core\Psr4Autoloader'                              => EE_Dependency_Map::load_from_cache,
810
+				'EventEspresso\core\services\addon\api\v1\RegisterAddon'         => EE_Dependency_Map::load_from_cache,
811
+				'EventEspresso\core\services\addon\api\IncompatibleAddonHandler' => EE_Dependency_Map::load_from_cache,
812
+				'EventEspresso\core\services\addon\api\ThirdPartyPluginHandler'  => EE_Dependency_Map::load_from_cache,
813
+			],
814
+			'EventEspresso\core\services\addon\api\ThirdPartyPluginHandler'                                               => [
815
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
816
+			],
817
+			'EventEspressoBatchRequest\JobHandlers\ExecuteBatchDeletion'                                                  => [
818
+				'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache,
819
+			],
820
+			'EventEspressoBatchRequest\JobHandlers\PreviewEventDeletion'                                                  => [
821
+				'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache,
822
+			],
823
+			'EventEspresso\core\domain\services\admin\events\data\PreviewDeletion'                                        => [
824
+				'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache,
825
+				'EEM_Event'                                                   => EE_Dependency_Map::load_from_cache,
826
+				'EEM_Datetime'                                                => EE_Dependency_Map::load_from_cache,
827
+				'EEM_Registration'                                            => EE_Dependency_Map::load_from_cache,
828
+			],
829
+			'EventEspresso\core\domain\services\admin\events\data\ConfirmDeletion'                                        => [
830
+				'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache,
831
+			],
832
+			'EventEspresso\core\services\request\CurrentPage'                                                             => [
833
+				'EE_CPT_Strategy'                             => EE_Dependency_Map::load_from_cache,
834
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
835
+			],
836
+			'EventEspresso\core\services\shortcodes\LegacyShortcodesManager'                                              => [
837
+				'EE_Registry'                                     => EE_Dependency_Map::load_from_cache,
838
+				'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache,
839
+			],
840
+			'EventEspresso\core\services\shortcodes\ShortcodesManager'                                                    => [
841
+				'EventEspresso\core\services\shortcodes\LegacyShortcodesManager' => EE_Dependency_Map::load_from_cache,
842
+				'EventEspresso\core\services\request\CurrentPage'                => EE_Dependency_Map::load_from_cache,
843
+			],
844
+			'EventEspresso\core\domain\entities\users\CurrentUser'                                                        => [
845
+				'EventEspresso\core\domain\entities\users\EventManagers' => EE_Dependency_Map::load_from_cache,
846
+			],
847
+			'EventEspresso\core\services\form\meta\InputTypes'                                                            => [
848
+				'EventEspresso\core\services\form\meta\inputs\Block'    => EE_Dependency_Map::load_from_cache,
849
+				'EventEspresso\core\services\form\meta\inputs\Button'   => EE_Dependency_Map::load_from_cache,
850
+				'EventEspresso\core\services\form\meta\inputs\DateTime' => EE_Dependency_Map::load_from_cache,
851
+				'EventEspresso\core\services\form\meta\inputs\Input'    => EE_Dependency_Map::load_from_cache,
852
+				'EventEspresso\core\services\form\meta\inputs\Number'   => EE_Dependency_Map::load_from_cache,
853
+				'EventEspresso\core\services\form\meta\inputs\Phone'    => EE_Dependency_Map::load_from_cache,
854
+				'EventEspresso\core\services\form\meta\inputs\Select'   => EE_Dependency_Map::load_from_cache,
855
+				'EventEspresso\core\services\form\meta\inputs\Text'     => EE_Dependency_Map::load_from_cache,
856
+			],
857
+			'EventEspresso\core\domain\services\registration\form\v1\RegFormDependencyHandler'                            => [
858
+				'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache,
859
+			],
860
+			'EventEspresso\core\services\calculators\LineItemCalculator'                                                  => [
861
+				'EventEspresso\core\services\helpers\DecimalValues' => EE_Dependency_Map::load_from_cache,
862
+			],
863
+			'EventEspresso\core\services\helpers\DecimalValues'                                                           => [
864
+				'EE_Currency_Config' => EE_Dependency_Map::load_from_cache,
865
+			],
866
+		];
867
+	}
868
+
869
+
870
+	/**
871
+	 * Registers how core classes are loaded.
872
+	 * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
873
+	 *        'EE_Request_Handler' => 'load_core'
874
+	 *        'EE_Messages_Queue'  => 'load_lib'
875
+	 *        'EEH_Debug_Tools'    => 'load_helper'
876
+	 * or, if greater control is required, by providing a custom closure. For example:
877
+	 *        'Some_Class' => function () {
878
+	 *            return new Some_Class();
879
+	 *        },
880
+	 * This is required for instantiating dependencies
881
+	 * where an interface has been type hinted in a class constructor. For example:
882
+	 *        'Required_Interface' => function () {
883
+	 *            return new A_Class_That_Implements_Required_Interface();
884
+	 *        },
885
+	 */
886
+	protected function _register_core_class_loaders()
887
+	{
888
+		$this->_class_loaders = [
889
+			// load_core
890
+			'EE_Dependency_Map'                            => function () {
891
+				return $this;
892
+			},
893
+			'EE_Capabilities'                              => 'load_core',
894
+			'EE_Encryption'                                => 'load_core',
895
+			'EE_Front_Controller'                          => 'load_core',
896
+			'EE_Module_Request_Router'                     => 'load_core',
897
+			'EE_Registry'                                  => 'load_core',
898
+			'EE_Request'                                   => function () {
899
+				return $this->legacy_request;
900
+			},
901
+			'EventEspresso\core\services\request\Request'  => function () {
902
+				return $this->request;
903
+			},
904
+			'EventEspresso\core\services\request\Response' => function () {
905
+				return $this->response;
906
+			},
907
+			'EE_Base'                                      => 'load_core',
908
+			'EE_Request_Handler'                           => 'load_core',
909
+			'EE_Session'                                   => 'load_core',
910
+			'EE_Cron_Tasks'                                => 'load_core',
911
+			'EE_System'                                    => 'load_core',
912
+			'EE_Maintenance_Mode'                          => 'load_core',
913
+			'EE_Register_CPTs'                             => 'load_core',
914
+			'EE_Admin'                                     => 'load_core',
915
+			'EE_CPT_Strategy'                              => 'load_core',
916
+			// load_class
917
+			'EE_Registration_Processor'                    => 'load_class',
918
+			// load_lib
919
+			'EE_Message_Resource_Manager'                  => 'load_lib',
920
+			'EE_Message_Type_Collection'                   => 'load_lib',
921
+			'EE_Message_Type_Collection_Loader'            => 'load_lib',
922
+			'EE_Messenger_Collection'                      => 'load_lib',
923
+			'EE_Messenger_Collection_Loader'               => 'load_lib',
924
+			'EE_Messages_Processor'                        => 'load_lib',
925
+			'EE_Message_Repository'                        => 'load_lib',
926
+			'EE_Messages_Queue'                            => 'load_lib',
927
+			'EE_Messages_Data_Handler_Collection'          => 'load_lib',
928
+			'EE_Message_Template_Group_Collection'         => 'load_lib',
929
+			'EE_Payment_Method_Manager'                    => 'load_lib',
930
+			'EE_DMS_Core_4_1_0'                            => 'load_dms',
931
+			'EE_DMS_Core_4_2_0'                            => 'load_dms',
932
+			'EE_DMS_Core_4_3_0'                            => 'load_dms',
933
+			'EE_DMS_Core_4_5_0'                            => 'load_dms',
934
+			'EE_DMS_Core_4_6_0'                            => 'load_dms',
935
+			'EE_DMS_Core_4_7_0'                            => 'load_dms',
936
+			'EE_DMS_Core_4_8_0'                            => 'load_dms',
937
+			'EE_DMS_Core_4_9_0'                            => 'load_dms',
938
+			'EE_DMS_Core_4_10_0'                           => 'load_dms',
939
+			'EE_DMS_Core_4_11_0'                           => 'load_dms',
940
+			'EE_DMS_Core_4_12_0'                           => 'load_dms',
941
+			'EE_Messages_Generator'                        => static function () {
942
+				return EE_Registry::instance()->load_lib(
943
+					'Messages_Generator',
944
+					[],
945
+					false,
946
+					false
947
+				);
948
+			},
949
+			'EE_Messages_Template_Defaults'                => static function ($arguments = []) {
950
+				return EE_Registry::instance()->load_lib(
951
+					'Messages_Template_Defaults',
952
+					$arguments,
953
+					false,
954
+					false
955
+				);
956
+			},
957
+			// load_helper
958
+			'EEH_Parse_Shortcodes'                         => static function () {
959
+				if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
960
+					return new EEH_Parse_Shortcodes();
961
+				}
962
+				return null;
963
+			},
964
+			'EE_Template_Config'                           => static function () {
965
+				return EE_Config::instance()->template_settings;
966
+			},
967
+			'EE_Currency_Config'                           => static function () {
968
+				return EE_Currency_Config::getCurrencyConfig();
969
+			},
970
+			'EE_Registration_Config'                       => static function () {
971
+				return EE_Config::instance()->registration;
972
+			},
973
+			'EE_Core_Config'                               => static function () {
974
+				return EE_Config::instance()->core;
975
+			},
976
+			'EventEspresso\core\services\loaders\Loader'   => static function () {
977
+				return LoaderFactory::getLoader();
978
+			},
979
+			'EE_Network_Config'                            => static function () {
980
+				return EE_Network_Config::instance();
981
+			},
982
+			'EE_Config'                                    => static function () {
983
+				return EE_Config::instance();
984
+			},
985
+			'EventEspresso\core\domain\Domain'             => static function () {
986
+				return DomainFactory::getEventEspressoCoreDomain();
987
+			},
988
+			'EE_Admin_Config'                              => static function () {
989
+				return EE_Config::instance()->admin;
990
+			},
991
+			'EE_Organization_Config'                       => static function () {
992
+				return EE_Config::instance()->organization;
993
+			},
994
+			'EE_Network_Core_Config'                       => static function () {
995
+				return EE_Network_Config::instance()->core;
996
+			},
997
+			'EE_Environment_Config'                        => static function () {
998
+				return EE_Config::instance()->environment;
999
+			},
1000
+			'EED_Core_Rest_Api'                            => static function () {
1001
+				return EED_Core_Rest_Api::instance();
1002
+			},
1003
+			'WP_REST_Server'                               => static function () {
1004
+				return rest_get_server();
1005
+			},
1006
+			'EventEspresso\core\Psr4Autoloader'            => static function () {
1007
+				return EE_Psr4AutoloaderInit::psr4_loader();
1008
+			},
1009
+			'EE_Ticket_Selector_Config'                    => function () {
1010
+				return EE_Config::instance()->template_settings->EED_Ticket_Selector;
1011
+			},
1012
+		];
1013
+	}
1014
+
1015
+
1016
+	/**
1017
+	 * can be used for supplying alternate names for classes,
1018
+	 * or for connecting interface names to instantiable classes
1019
+	 *
1020
+	 * @throws InvalidAliasException
1021
+	 */
1022
+	protected function _register_core_aliases()
1023
+	{
1024
+		$aliases = [
1025
+			'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
1026
+			'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
1027
+			'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
1028
+			'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
1029
+			'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
1030
+			'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
1031
+			'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1032
+			'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
1033
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1034
+			'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
1035
+			'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
1036
+			'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
1037
+			'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
1038
+			'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
1039
+			'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
1040
+			'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
1041
+			'CreateTransactionCommandHandler'                                              => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
1042
+			'CreateAttendeeCommandHandler'                                                 => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
1043
+			'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
1044
+			'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
1045
+			'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1046
+			'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
1047
+			'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1048
+			'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
1049
+			'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
1050
+			'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
1051
+			'CommandFactoryInterface'                                                      => 'EventEspresso\core\services\commands\CommandFactoryInterface',
1052
+			'EventEspresso\core\services\commands\CommandFactoryInterface'                 => 'EventEspresso\core\services\commands\CommandFactory',
1053
+			'EmailValidatorInterface'                                                      => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
1054
+			'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface'  => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
1055
+			'NoticeConverterInterface'                                                     => 'EventEspresso\core\services\notices\NoticeConverterInterface',
1056
+			'EventEspresso\core\services\notices\NoticeConverterInterface'                 => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
1057
+			'NoticesContainerInterface'                                                    => 'EventEspresso\core\services\notices\NoticesContainerInterface',
1058
+			'EventEspresso\core\services\notices\NoticesContainerInterface'                => 'EventEspresso\core\services\notices\NoticesContainer',
1059
+			'EventEspresso\core\services\request\RequestInterface'                         => 'EventEspresso\core\services\request\Request',
1060
+			'EventEspresso\core\services\request\ResponseInterface'                        => 'EventEspresso\core\services\request\Response',
1061
+			'EventEspresso\core\domain\DomainInterface'                                    => 'EventEspresso\core\domain\Domain',
1062
+			'Registration_Processor'                                                       => 'EE_Registration_Processor',
1063
+			'EventEspresso\core\services\assets\AssetManifestInterface'                    => 'EventEspresso\core\services\assets\AssetManifest',
1064
+		];
1065
+		foreach ($aliases as $alias => $fqn) {
1066
+			if (is_array($fqn)) {
1067
+				foreach ($fqn as $class => $for_class) {
1068
+					$this->class_cache->addAlias($class, $alias, $for_class);
1069
+				}
1070
+				continue;
1071
+			}
1072
+			$this->class_cache->addAlias($fqn, $alias);
1073
+		}
1074
+		if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
1075
+			$this->class_cache->addAlias(
1076
+				'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
1077
+				'EventEspresso\core\services\notices\NoticeConverterInterface'
1078
+			);
1079
+		}
1080
+	}
1081
+
1082
+
1083
+	public function debug($for_class = '')
1084
+	{
1085
+		if (method_exists($this->class_cache, 'debug')) {
1086
+			$this->class_cache->debug($for_class);
1087
+		}
1088
+	}
1089
+
1090
+
1091
+	/**
1092
+	 * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
1093
+	 * request Primarily used by unit tests.
1094
+	 */
1095
+	public function reset()
1096
+	{
1097
+		$this->_register_core_class_loaders();
1098
+		$this->_register_core_dependencies();
1099
+	}
1100
+
1101
+
1102
+	/**
1103
+	 * PLZ NOTE: a better name for this method would be is_alias()
1104
+	 * because it returns TRUE if the provided fully qualified name IS an alias
1105
+	 * WHY?
1106
+	 * Because if a class is type hinting for a concretion,
1107
+	 * then why would we need to find another class to supply it?
1108
+	 * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
1109
+	 * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
1110
+	 * Don't go looking for some substitute.
1111
+	 * Whereas if a class is type hinting for an interface...
1112
+	 * then we need to find an actual class to use.
1113
+	 * So the interface IS the alias for some other FQN,
1114
+	 * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
1115
+	 * represents some other class.
1116
+	 *
1117
+	 * @param string $fqn
1118
+	 * @param string $for_class
1119
+	 * @return bool
1120
+	 * @deprecated 4.9.62.p
1121
+	 */
1122
+	public function has_alias(string $fqn = '', string $for_class = ''): bool
1123
+	{
1124
+		return $this->isAlias($fqn, $for_class);
1125
+	}
1126
+
1127
+
1128
+	/**
1129
+	 * PLZ NOTE: a better name for this method would be get_fqn_for_alias()
1130
+	 * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias
1131
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
1132
+	 *  for example:
1133
+	 *      if the following two entries were added to the _aliases array:
1134
+	 *          array(
1135
+	 *              'interface_alias'           => 'some\namespace\interface'
1136
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
1137
+	 *          )
1138
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
1139
+	 *      to load an instance of 'some\namespace\classname'
1140
+	 *
1141
+	 * @param string $alias
1142
+	 * @param string $for_class
1143
+	 * @return string
1144
+	 * @deprecated 4.9.62.p
1145
+	 */
1146
+	public function get_alias(string $alias = '', string $for_class = ''): string
1147
+	{
1148
+		return $this->getFqnForAlias($alias, $for_class);
1149
+	}
1150 1150
 }
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -205,8 +205,8 @@  discard block
 block discarded – undo
205 205
     ): bool {
206 206
         $class      = trim($class, '\\');
207 207
         $registered = false;
208
-        if (empty(EE_Dependency_Map::$_instance->_dependency_map[ $class ])) {
209
-            EE_Dependency_Map::$_instance->_dependency_map[ $class ] = [];
208
+        if (empty(EE_Dependency_Map::$_instance->_dependency_map[$class])) {
209
+            EE_Dependency_Map::$_instance->_dependency_map[$class] = [];
210 210
         }
211 211
         // we need to make sure that any aliases used when registering a dependency
212 212
         // get resolved to the correct class name
@@ -214,10 +214,10 @@  discard block
 block discarded – undo
214 214
             $alias = EE_Dependency_Map::$_instance->getFqnForAlias($dependency);
215 215
             if (
216 216
                 $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
217
-                || ! isset(EE_Dependency_Map::$_instance->_dependency_map[ $class ][ $alias ])
217
+                || ! isset(EE_Dependency_Map::$_instance->_dependency_map[$class][$alias])
218 218
             ) {
219
-                unset($dependencies[ $dependency ]);
220
-                $dependencies[ $alias ] = $load_source;
219
+                unset($dependencies[$dependency]);
220
+                $dependencies[$alias] = $load_source;
221 221
                 $registered             = true;
222 222
             }
223 223
         }
@@ -227,13 +227,13 @@  discard block
 block discarded – undo
227 227
         // ie: with A = B + C, entries in B take precedence over duplicate entries in C
228 228
         // Union is way faster than array_merge() but should be used with caution...
229 229
         // especially with numerically indexed arrays
230
-        $dependencies += EE_Dependency_Map::$_instance->_dependency_map[ $class ];
230
+        $dependencies += EE_Dependency_Map::$_instance->_dependency_map[$class];
231 231
         // now we need to ensure that the resulting dependencies
232 232
         // array only has the entries that are required for the class
233 233
         // so first count how many dependencies were originally registered for the class
234
-        $dependency_count = count(EE_Dependency_Map::$_instance->_dependency_map[ $class ]);
234
+        $dependency_count = count(EE_Dependency_Map::$_instance->_dependency_map[$class]);
235 235
         // if that count is non-zero (meaning dependencies were already registered)
236
-        EE_Dependency_Map::$_instance->_dependency_map[ $class ] = $dependency_count
236
+        EE_Dependency_Map::$_instance->_dependency_map[$class] = $dependency_count
237 237
             // then truncate the  final array to match that count
238 238
             ? array_slice($dependencies, 0, $dependency_count)
239 239
             // otherwise just take the incoming array because nothing previously existed
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
      */
268 268
     public function registerClassLoader(string $class_name, $loader = 'load_core', bool $overwrite = false): bool
269 269
     {
270
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
270
+        if ( ! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
271 271
             throw new DomainException(
272 272
                 esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
273 273
             );
@@ -291,8 +291,8 @@  discard block
 block discarded – undo
291 291
             );
292 292
         }
293 293
         $class_name = EE_Dependency_Map::$_instance->getFqnForAlias($class_name);
294
-        if ($overwrite || ! isset(EE_Dependency_Map::$_instance->_class_loaders[ $class_name ])) {
295
-            EE_Dependency_Map::$_instance->_class_loaders[ $class_name ] = $loader;
294
+        if ($overwrite || ! isset(EE_Dependency_Map::$_instance->_class_loaders[$class_name])) {
295
+            EE_Dependency_Map::$_instance->_class_loaders[$class_name] = $loader;
296 296
             return true;
297 297
         }
298 298
         return false;
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
         if (strpos($class_name, 'EEM_') === 0) {
321 321
             $class_name = 'LEGACY_MODELS';
322 322
         }
323
-        return isset($this->_dependency_map[ $class_name ]);
323
+        return isset($this->_dependency_map[$class_name]);
324 324
     }
325 325
 
326 326
 
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
             $class_name = 'LEGACY_MODELS';
339 339
         }
340 340
         $dependency = $this->getFqnForAlias($dependency, $class_name);
341
-        return isset($this->_dependency_map[ $class_name ][ $dependency ]);
341
+        return isset($this->_dependency_map[$class_name][$dependency]);
342 342
     }
343 343
 
344 344
 
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
         }
358 358
         $dependency = $this->getFqnForAlias($dependency);
359 359
         return $this->has_dependency_for_class($class_name, $dependency)
360
-            ? $this->_dependency_map[ $class_name ][ $dependency ]
360
+            ? $this->_dependency_map[$class_name][$dependency]
361 361
             : EE_Dependency_Map::not_registered;
362 362
     }
363 363
 
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
             return 'load_core';
382 382
         }
383 383
         $class_name = $this->getFqnForAlias($class_name);
384
-        return $this->_class_loaders[ $class_name ] ?? '';
384
+        return $this->_class_loaders[$class_name] ?? '';
385 385
     }
386 386
 
387 387
 
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
     {
888 888
         $this->_class_loaders = [
889 889
             // load_core
890
-            'EE_Dependency_Map'                            => function () {
890
+            'EE_Dependency_Map'                            => function() {
891 891
                 return $this;
892 892
             },
893 893
             'EE_Capabilities'                              => 'load_core',
@@ -895,13 +895,13 @@  discard block
 block discarded – undo
895 895
             'EE_Front_Controller'                          => 'load_core',
896 896
             'EE_Module_Request_Router'                     => 'load_core',
897 897
             'EE_Registry'                                  => 'load_core',
898
-            'EE_Request'                                   => function () {
898
+            'EE_Request'                                   => function() {
899 899
                 return $this->legacy_request;
900 900
             },
901
-            'EventEspresso\core\services\request\Request'  => function () {
901
+            'EventEspresso\core\services\request\Request'  => function() {
902 902
                 return $this->request;
903 903
             },
904
-            'EventEspresso\core\services\request\Response' => function () {
904
+            'EventEspresso\core\services\request\Response' => function() {
905 905
                 return $this->response;
906 906
             },
907 907
             'EE_Base'                                      => 'load_core',
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
             'EE_DMS_Core_4_10_0'                           => 'load_dms',
939 939
             'EE_DMS_Core_4_11_0'                           => 'load_dms',
940 940
             'EE_DMS_Core_4_12_0'                           => 'load_dms',
941
-            'EE_Messages_Generator'                        => static function () {
941
+            'EE_Messages_Generator'                        => static function() {
942 942
                 return EE_Registry::instance()->load_lib(
943 943
                     'Messages_Generator',
944 944
                     [],
@@ -946,7 +946,7 @@  discard block
 block discarded – undo
946 946
                     false
947 947
                 );
948 948
             },
949
-            'EE_Messages_Template_Defaults'                => static function ($arguments = []) {
949
+            'EE_Messages_Template_Defaults'                => static function($arguments = []) {
950 950
                 return EE_Registry::instance()->load_lib(
951 951
                     'Messages_Template_Defaults',
952 952
                     $arguments,
@@ -955,58 +955,58 @@  discard block
 block discarded – undo
955 955
                 );
956 956
             },
957 957
             // load_helper
958
-            'EEH_Parse_Shortcodes'                         => static function () {
958
+            'EEH_Parse_Shortcodes'                         => static function() {
959 959
                 if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
960 960
                     return new EEH_Parse_Shortcodes();
961 961
                 }
962 962
                 return null;
963 963
             },
964
-            'EE_Template_Config'                           => static function () {
964
+            'EE_Template_Config'                           => static function() {
965 965
                 return EE_Config::instance()->template_settings;
966 966
             },
967
-            'EE_Currency_Config'                           => static function () {
967
+            'EE_Currency_Config'                           => static function() {
968 968
                 return EE_Currency_Config::getCurrencyConfig();
969 969
             },
970
-            'EE_Registration_Config'                       => static function () {
970
+            'EE_Registration_Config'                       => static function() {
971 971
                 return EE_Config::instance()->registration;
972 972
             },
973
-            'EE_Core_Config'                               => static function () {
973
+            'EE_Core_Config'                               => static function() {
974 974
                 return EE_Config::instance()->core;
975 975
             },
976
-            'EventEspresso\core\services\loaders\Loader'   => static function () {
976
+            'EventEspresso\core\services\loaders\Loader'   => static function() {
977 977
                 return LoaderFactory::getLoader();
978 978
             },
979
-            'EE_Network_Config'                            => static function () {
979
+            'EE_Network_Config'                            => static function() {
980 980
                 return EE_Network_Config::instance();
981 981
             },
982
-            'EE_Config'                                    => static function () {
982
+            'EE_Config'                                    => static function() {
983 983
                 return EE_Config::instance();
984 984
             },
985
-            'EventEspresso\core\domain\Domain'             => static function () {
985
+            'EventEspresso\core\domain\Domain'             => static function() {
986 986
                 return DomainFactory::getEventEspressoCoreDomain();
987 987
             },
988
-            'EE_Admin_Config'                              => static function () {
988
+            'EE_Admin_Config'                              => static function() {
989 989
                 return EE_Config::instance()->admin;
990 990
             },
991
-            'EE_Organization_Config'                       => static function () {
991
+            'EE_Organization_Config'                       => static function() {
992 992
                 return EE_Config::instance()->organization;
993 993
             },
994
-            'EE_Network_Core_Config'                       => static function () {
994
+            'EE_Network_Core_Config'                       => static function() {
995 995
                 return EE_Network_Config::instance()->core;
996 996
             },
997
-            'EE_Environment_Config'                        => static function () {
997
+            'EE_Environment_Config'                        => static function() {
998 998
                 return EE_Config::instance()->environment;
999 999
             },
1000
-            'EED_Core_Rest_Api'                            => static function () {
1000
+            'EED_Core_Rest_Api'                            => static function() {
1001 1001
                 return EED_Core_Rest_Api::instance();
1002 1002
             },
1003
-            'WP_REST_Server'                               => static function () {
1003
+            'WP_REST_Server'                               => static function() {
1004 1004
                 return rest_get_server();
1005 1005
             },
1006
-            'EventEspresso\core\Psr4Autoloader'            => static function () {
1006
+            'EventEspresso\core\Psr4Autoloader'            => static function() {
1007 1007
                 return EE_Psr4AutoloaderInit::psr4_loader();
1008 1008
             },
1009
-            'EE_Ticket_Selector_Config'                    => function () {
1009
+            'EE_Ticket_Selector_Config'                    => function() {
1010 1010
                 return EE_Config::instance()->template_settings->EED_Ticket_Selector;
1011 1011
             },
1012 1012
         ];
@@ -1071,7 +1071,7 @@  discard block
 block discarded – undo
1071 1071
             }
1072 1072
             $this->class_cache->addAlias($fqn, $alias);
1073 1073
         }
1074
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
1074
+        if ( ! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
1075 1075
             $this->class_cache->addAlias(
1076 1076
                 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
1077 1077
                 'EventEspresso\core\services\notices\NoticeConverterInterface'
Please login to merge, or discard this patch.
core/db_models/EEM_Price.model.php 2 patches
Indentation   +337 added lines, -337 removed lines patch added patch discarded remove patch
@@ -13,368 +13,368 @@
 block discarded – undo
13 13
 class EEM_Price extends EEM_Soft_Delete_Base
14 14
 {
15 15
 
16
-    // private instance of the EEM_Price object
17
-    protected static $_instance;
16
+	// private instance of the EEM_Price object
17
+	protected static $_instance;
18 18
 
19 19
 
20
-    /**
21
-     * private constructor to prevent direct creation
22
-     *
23
-     * @Constructor
24
-     * @param string $timezone string representing the timezone we want to set for returned Date Time Strings
25
-     *                         (and any incoming timezone data that gets saved).
26
-     *                         Note this just sends the timezone info to the date time model field objects.
27
-     *                         Default is NULL
28
-     *                         (and will be assumed using the set timezone in the 'timezone_string' wp option)
29
-     */
30
-    protected function __construct($timezone)
31
-    {
32
-        $this->singular_item = __('Price', 'event_espresso');
33
-        $this->plural_item   = __('Prices', 'event_espresso');
20
+	/**
21
+	 * private constructor to prevent direct creation
22
+	 *
23
+	 * @Constructor
24
+	 * @param string $timezone string representing the timezone we want to set for returned Date Time Strings
25
+	 *                         (and any incoming timezone data that gets saved).
26
+	 *                         Note this just sends the timezone info to the date time model field objects.
27
+	 *                         Default is NULL
28
+	 *                         (and will be assumed using the set timezone in the 'timezone_string' wp option)
29
+	 */
30
+	protected function __construct($timezone)
31
+	{
32
+		$this->singular_item = __('Price', 'event_espresso');
33
+		$this->plural_item   = __('Prices', 'event_espresso');
34 34
 
35
-        $this->_tables          = [
36
-            'Price' => new EE_Primary_Table('esp_price', 'PRC_ID'),
37
-        ];
38
-        $this->_fields          = [
39
-            'Price' => [
40
-                'PRC_ID'         => new EE_Primary_Key_Int_Field(
41
-                    'PRC_ID',
42
-                    'Price ID'
43
-                ),
44
-                'PRT_ID'         => new EE_Foreign_Key_Int_Field(
45
-                    'PRT_ID',
46
-                    esc_html__('Price type Id', 'event_espresso'),
47
-                    false,
48
-                    null,
49
-                    'Price_Type'
50
-                ),
51
-                'PRC_amount'     => new EE_Money_Field(
52
-                    'PRC_amount',
53
-                    esc_html__('Price Amount', 'event_espresso'),
54
-                    false,
55
-                    0
56
-                ),
57
-                'PRC_name'       => new EE_Plain_Text_Field(
58
-                    'PRC_name',
59
-                    esc_html__('Name of Price', 'event_espresso'),
60
-                    false,
61
-                    ''
62
-                ),
63
-                'PRC_desc'       => new EE_Post_Content_Field(
64
-                    'PRC_desc',
65
-                    esc_html__('Price Description', 'event_espresso'),
66
-                    false,
67
-                    ''
68
-                ),
69
-                'PRC_is_default' => new EE_Boolean_Field(
70
-                    'PRC_is_default',
71
-                    esc_html__('Flag indicating whether price is a default price', 'event_espresso'),
72
-                    false,
73
-                    false
74
-                ),
75
-                'PRC_overrides'  => new EE_Integer_Field(
76
-                    'PRC_overrides',
77
-                    esc_html__(
78
-                        'Price ID for a global Price that will be overridden by this Price  ( for replacing default prices )',
79
-                        'event_espresso'
80
-                    ),
81
-                    true,
82
-                    0
83
-                ),
84
-                'PRC_order'      => new EE_Integer_Field(
85
-                    'PRC_order',
86
-                    esc_html__(
87
-                        'Order of Application of Price (lower numbers apply first?)',
88
-                        'event_espresso'
89
-                    ),
90
-                    false,
91
-                    1
92
-                ),
93
-                'PRC_deleted'    => new EE_Trashed_Flag_Field(
94
-                    'PRC_deleted',
95
-                    esc_html__('Flag Indicating if this has been deleted or not', 'event_espresso'),
96
-                    false,
97
-                    false
98
-                ),
99
-                'PRC_parent'     => new EE_Integer_Field(
100
-                    'PRC_parent',
101
-                    esc_html__('Indicates what PRC_ID is the parent of this PRC_ID', 'event_espresso'),
102
-                    true,
103
-                    0
104
-                ),
105
-                'PRC_wp_user'    => new EE_WP_User_Field(
106
-                    'PRC_wp_user',
107
-                    esc_html__('Price Creator ID', 'event_espresso'),
108
-                    false
109
-                ),
110
-            ],
111
-        ];
112
-        $this->_model_relations = [
113
-            'Ticket'     => new EE_HABTM_Relation('Ticket_Price'),
114
-            'Price_Type' => new EE_Belongs_To_Relation(),
115
-            'WP_User'    => new EE_Belongs_To_Relation(),
116
-        ];
117
-        // this model is generally available for reading
118
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] =
119
-            new EE_Restriction_Generator_Default_Public(
120
-                'PRC_is_default',
121
-                'Ticket.Datetime.Event'
122
-            );
123
-        // account for default tickets in the caps
124
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] =
125
-            new EE_Restriction_Generator_Default_Protected(
126
-                'PRC_is_default',
127
-                'Ticket.Datetime.Event'
128
-            );
129
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ]       =
130
-            new EE_Restriction_Generator_Default_Protected(
131
-                'PRC_is_default',
132
-                'Ticket.Datetime.Event'
133
-            );
134
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ]     =
135
-            new EE_Restriction_Generator_Default_Protected(
136
-                'PRC_is_default',
137
-                'Ticket.Datetime.Event'
138
-            );
139
-        parent::__construct($timezone);
140
-    }
35
+		$this->_tables          = [
36
+			'Price' => new EE_Primary_Table('esp_price', 'PRC_ID'),
37
+		];
38
+		$this->_fields          = [
39
+			'Price' => [
40
+				'PRC_ID'         => new EE_Primary_Key_Int_Field(
41
+					'PRC_ID',
42
+					'Price ID'
43
+				),
44
+				'PRT_ID'         => new EE_Foreign_Key_Int_Field(
45
+					'PRT_ID',
46
+					esc_html__('Price type Id', 'event_espresso'),
47
+					false,
48
+					null,
49
+					'Price_Type'
50
+				),
51
+				'PRC_amount'     => new EE_Money_Field(
52
+					'PRC_amount',
53
+					esc_html__('Price Amount', 'event_espresso'),
54
+					false,
55
+					0
56
+				),
57
+				'PRC_name'       => new EE_Plain_Text_Field(
58
+					'PRC_name',
59
+					esc_html__('Name of Price', 'event_espresso'),
60
+					false,
61
+					''
62
+				),
63
+				'PRC_desc'       => new EE_Post_Content_Field(
64
+					'PRC_desc',
65
+					esc_html__('Price Description', 'event_espresso'),
66
+					false,
67
+					''
68
+				),
69
+				'PRC_is_default' => new EE_Boolean_Field(
70
+					'PRC_is_default',
71
+					esc_html__('Flag indicating whether price is a default price', 'event_espresso'),
72
+					false,
73
+					false
74
+				),
75
+				'PRC_overrides'  => new EE_Integer_Field(
76
+					'PRC_overrides',
77
+					esc_html__(
78
+						'Price ID for a global Price that will be overridden by this Price  ( for replacing default prices )',
79
+						'event_espresso'
80
+					),
81
+					true,
82
+					0
83
+				),
84
+				'PRC_order'      => new EE_Integer_Field(
85
+					'PRC_order',
86
+					esc_html__(
87
+						'Order of Application of Price (lower numbers apply first?)',
88
+						'event_espresso'
89
+					),
90
+					false,
91
+					1
92
+				),
93
+				'PRC_deleted'    => new EE_Trashed_Flag_Field(
94
+					'PRC_deleted',
95
+					esc_html__('Flag Indicating if this has been deleted or not', 'event_espresso'),
96
+					false,
97
+					false
98
+				),
99
+				'PRC_parent'     => new EE_Integer_Field(
100
+					'PRC_parent',
101
+					esc_html__('Indicates what PRC_ID is the parent of this PRC_ID', 'event_espresso'),
102
+					true,
103
+					0
104
+				),
105
+				'PRC_wp_user'    => new EE_WP_User_Field(
106
+					'PRC_wp_user',
107
+					esc_html__('Price Creator ID', 'event_espresso'),
108
+					false
109
+				),
110
+			],
111
+		];
112
+		$this->_model_relations = [
113
+			'Ticket'     => new EE_HABTM_Relation('Ticket_Price'),
114
+			'Price_Type' => new EE_Belongs_To_Relation(),
115
+			'WP_User'    => new EE_Belongs_To_Relation(),
116
+		];
117
+		// this model is generally available for reading
118
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] =
119
+			new EE_Restriction_Generator_Default_Public(
120
+				'PRC_is_default',
121
+				'Ticket.Datetime.Event'
122
+			);
123
+		// account for default tickets in the caps
124
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] =
125
+			new EE_Restriction_Generator_Default_Protected(
126
+				'PRC_is_default',
127
+				'Ticket.Datetime.Event'
128
+			);
129
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ]       =
130
+			new EE_Restriction_Generator_Default_Protected(
131
+				'PRC_is_default',
132
+				'Ticket.Datetime.Event'
133
+			);
134
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ]     =
135
+			new EE_Restriction_Generator_Default_Protected(
136
+				'PRC_is_default',
137
+				'Ticket.Datetime.Event'
138
+			);
139
+		parent::__construct($timezone);
140
+	}
141 141
 
142 142
 
143
-    /**
144
-     * instantiate a new price object with blank/empty properties
145
-     *
146
-     * @return mixed array on success, FALSE on fail
147
-     */
148
-    public function get_new_price()
149
-    {
150
-        return $this->create_default_object();
151
-    }
143
+	/**
144
+	 * instantiate a new price object with blank/empty properties
145
+	 *
146
+	 * @return mixed array on success, FALSE on fail
147
+	 */
148
+	public function get_new_price()
149
+	{
150
+		return $this->create_default_object();
151
+	}
152 152
 
153 153
 
154
-    /**
155
-     * retrieve  ALL prices from db
156
-     *
157
-     * @return EE_Base_Class[]|EE_PRice[]
158
-     * @throws EE_Error
159
-     */
160
-    public function get_all_prices()
161
-    {
162
-        // retrieve all prices
163
-        return $this->get_all(['order_by' => ['PRC_amount' => 'ASC']]);
164
-    }
154
+	/**
155
+	 * retrieve  ALL prices from db
156
+	 *
157
+	 * @return EE_Base_Class[]|EE_PRice[]
158
+	 * @throws EE_Error
159
+	 */
160
+	public function get_all_prices()
161
+	{
162
+		// retrieve all prices
163
+		return $this->get_all(['order_by' => ['PRC_amount' => 'ASC']]);
164
+	}
165 165
 
166 166
 
167
-    /**
168
-     * retrieve all active prices for a particular event
169
-     *
170
-     * @param int $EVT_ID
171
-     * @return array on success
172
-     * @throws EE_Error
173
-     */
174
-    public function get_all_event_prices($EVT_ID = 0)
175
-    {
176
-        return $this->get_all(
177
-            [
178
-                [
179
-                    'EVT_ID'            => $EVT_ID,
180
-                    'Price_Type.PBT_ID' => ['!=', EEM_Price_Type::base_type_tax],
181
-                ],
182
-                'order_by' => $this->_order_by_array_for_get_all_method(),
183
-            ]
184
-        );
185
-    }
167
+	/**
168
+	 * retrieve all active prices for a particular event
169
+	 *
170
+	 * @param int $EVT_ID
171
+	 * @return array on success
172
+	 * @throws EE_Error
173
+	 */
174
+	public function get_all_event_prices($EVT_ID = 0)
175
+	{
176
+		return $this->get_all(
177
+			[
178
+				[
179
+					'EVT_ID'            => $EVT_ID,
180
+					'Price_Type.PBT_ID' => ['!=', EEM_Price_Type::base_type_tax],
181
+				],
182
+				'order_by' => $this->_order_by_array_for_get_all_method(),
183
+			]
184
+		);
185
+	}
186 186
 
187 187
 
188
-    /**
189
-     * retrieve all active global prices (that are not taxes (PBT_ID=4)) for a particular event
190
-     *
191
-     * @param boolean $count return count
192
-     * @param bool    $include_taxes
193
-     * @return bool|EE_Base_Class[]|EE_PRice[]
194
-     * @throws EE_Error
195
-     */
196
-    public function get_all_default_prices($count = false, $include_taxes = false)
197
-    {
198
-        $_where = [
199
-            'PRC_deleted'    => 0,
200
-            'PRC_is_default' => 1,
201
-        ];
202
-        if (! $include_taxes) {
203
-            $_where['Price_Type.PBT_ID'] = ['!=', 4];
204
-        }
205
-        $_query_params = [
206
-            $_where,
207
-            'order_by' => $this->_order_by_array_for_get_all_method(),
208
-        ];
209
-        return $count ? $this->count([$_where]) : $this->get_all($_query_params);
210
-    }
188
+	/**
189
+	 * retrieve all active global prices (that are not taxes (PBT_ID=4)) for a particular event
190
+	 *
191
+	 * @param boolean $count return count
192
+	 * @param bool    $include_taxes
193
+	 * @return bool|EE_Base_Class[]|EE_PRice[]
194
+	 * @throws EE_Error
195
+	 */
196
+	public function get_all_default_prices($count = false, $include_taxes = false)
197
+	{
198
+		$_where = [
199
+			'PRC_deleted'    => 0,
200
+			'PRC_is_default' => 1,
201
+		];
202
+		if (! $include_taxes) {
203
+			$_where['Price_Type.PBT_ID'] = ['!=', 4];
204
+		}
205
+		$_query_params = [
206
+			$_where,
207
+			'order_by' => $this->_order_by_array_for_get_all_method(),
208
+		];
209
+		return $count ? $this->count([$_where]) : $this->get_all($_query_params);
210
+	}
211 211
 
212 212
 
213
-    /**
214
-     * retrieve all active global prices that are taxes
215
-     *
216
-     * @return bool|EE_Base_Class[]|EE_PRice[]
217
-     * @throws EE_Error
218
-     * @since   $VID:$
219
-     */
220
-    public function getAllDefaultTaxes()
221
-    {
222
-        return $this->get_all(
223
-            [
224
-                [
225
-                    'PRC_deleted'    => 0,
226
-                    'PRC_is_default' => 1,
227
-                    'Price_Type.PBT_ID' => EEM_Price_Type::base_type_tax
228
-                ],
229
-                'order_by' => [
230
-                    'Price_Type.PRT_order' => 'ASC',
231
-                    'PRC_order' => 'ASC'
232
-                ],
233
-            ]
234
-        );
235
-    }
213
+	/**
214
+	 * retrieve all active global prices that are taxes
215
+	 *
216
+	 * @return bool|EE_Base_Class[]|EE_PRice[]
217
+	 * @throws EE_Error
218
+	 * @since   $VID:$
219
+	 */
220
+	public function getAllDefaultTaxes()
221
+	{
222
+		return $this->get_all(
223
+			[
224
+				[
225
+					'PRC_deleted'    => 0,
226
+					'PRC_is_default' => 1,
227
+					'Price_Type.PBT_ID' => EEM_Price_Type::base_type_tax
228
+				],
229
+				'order_by' => [
230
+					'Price_Type.PRT_order' => 'ASC',
231
+					'PRC_order' => 'ASC'
232
+				],
233
+			]
234
+		);
235
+	}
236 236
 
237 237
 
238
-    /**
239
-     * retrieve all prices that are taxes
240
-     *
241
-     * @return EE_Base_Class[]|EE_PRice[]
242
-     * @throws EE_Error
243
-     * @throws InvalidArgumentException
244
-     * @throws ReflectionException
245
-     * @throws InvalidDataTypeException
246
-     * @throws InvalidInterfaceException
247
-     */
248
-    public function get_all_prices_that_are_taxes()
249
-    {
250
-        $taxes     = [];
251
-        $all_taxes = $this->get_all(
252
-            [
253
-                ['Price_Type.PBT_ID' => EEM_Price_Type::base_type_tax, 'PRC_is_default' => 1],
254
-                'order_by' => ['Price_Type.PRT_order' => 'ASC', 'PRC_order' => 'ASC'],
255
-            ]
256
-        );
257
-        foreach ($all_taxes as $tax) {
258
-            if ($tax instanceof EE_Price) {
259
-                $taxes[ $tax->order() ][ $tax->ID() ] = $tax;
260
-            }
261
-        }
262
-        return $taxes;
263
-    }
238
+	/**
239
+	 * retrieve all prices that are taxes
240
+	 *
241
+	 * @return EE_Base_Class[]|EE_PRice[]
242
+	 * @throws EE_Error
243
+	 * @throws InvalidArgumentException
244
+	 * @throws ReflectionException
245
+	 * @throws InvalidDataTypeException
246
+	 * @throws InvalidInterfaceException
247
+	 */
248
+	public function get_all_prices_that_are_taxes()
249
+	{
250
+		$taxes     = [];
251
+		$all_taxes = $this->get_all(
252
+			[
253
+				['Price_Type.PBT_ID' => EEM_Price_Type::base_type_tax, 'PRC_is_default' => 1],
254
+				'order_by' => ['Price_Type.PRT_order' => 'ASC', 'PRC_order' => 'ASC'],
255
+			]
256
+		);
257
+		foreach ($all_taxes as $tax) {
258
+			if ($tax instanceof EE_Price) {
259
+				$taxes[ $tax->order() ][ $tax->ID() ] = $tax;
260
+			}
261
+		}
262
+		return $taxes;
263
+	}
264 264
 
265 265
 
266
-    /**
267
-     * retrieve all prices for an ticket plus default global prices, but not taxes
268
-     *
269
-     * @param int $TKT_ID the id of the event.  If not included then we assume that this is a new ticket.
270
-     * @return EE_Base_Class[]|EE_PRice[]|boolean
271
-     * @throws EE_Error
272
-     */
273
-    public function get_all_ticket_prices_for_admin($TKT_ID = 0)
274
-    {
275
-        $array_of_price_objects = [];
276
-        if (empty($TKT_ID)) {
277
-            // if there is no tkt, get prices with no tkt ID, are global, are not a tax, and are active
278
-            // return that list
279
-            $default_prices = $this->get_all_default_prices();
266
+	/**
267
+	 * retrieve all prices for an ticket plus default global prices, but not taxes
268
+	 *
269
+	 * @param int $TKT_ID the id of the event.  If not included then we assume that this is a new ticket.
270
+	 * @return EE_Base_Class[]|EE_PRice[]|boolean
271
+	 * @throws EE_Error
272
+	 */
273
+	public function get_all_ticket_prices_for_admin($TKT_ID = 0)
274
+	{
275
+		$array_of_price_objects = [];
276
+		if (empty($TKT_ID)) {
277
+			// if there is no tkt, get prices with no tkt ID, are global, are not a tax, and are active
278
+			// return that list
279
+			$default_prices = $this->get_all_default_prices();
280 280
 
281
-            if ($default_prices) {
282
-                foreach ($default_prices as $price) {
283
-                    if ($price instanceof EE_Price) {
284
-                        $array_of_price_objects[ $price->type() ][] = $price;
285
-                    }
286
-                }
287
-                return $array_of_price_objects;
288
-            }
289
-            return [];
290
-        }
291
-        $ticket_prices = $this->get_all(
292
-            [
293
-                [
294
-                    'TKT_ID'      => $TKT_ID,
295
-                    'PRC_deleted' => 0,
296
-                ],
297
-                'order_by' => ['PRC_order' => 'ASC'],
298
-            ]
299
-        );
281
+			if ($default_prices) {
282
+				foreach ($default_prices as $price) {
283
+					if ($price instanceof EE_Price) {
284
+						$array_of_price_objects[ $price->type() ][] = $price;
285
+					}
286
+				}
287
+				return $array_of_price_objects;
288
+			}
289
+			return [];
290
+		}
291
+		$ticket_prices = $this->get_all(
292
+			[
293
+				[
294
+					'TKT_ID'      => $TKT_ID,
295
+					'PRC_deleted' => 0,
296
+				],
297
+				'order_by' => ['PRC_order' => 'ASC'],
298
+			]
299
+		);
300 300
 
301
-        if (! empty($ticket_prices)) {
302
-            foreach ($ticket_prices as $price) {
303
-                if ($price instanceof EE_Price) {
304
-                    $array_of_price_objects[ $price->type() ][] = $price;
305
-                }
306
-            }
307
-            return $array_of_price_objects;
308
-        }
309
-        return false;
310
-    }
301
+		if (! empty($ticket_prices)) {
302
+			foreach ($ticket_prices as $price) {
303
+				if ($price instanceof EE_Price) {
304
+					$array_of_price_objects[ $price->type() ][] = $price;
305
+				}
306
+			}
307
+			return $array_of_price_objects;
308
+		}
309
+		return false;
310
+	}
311 311
 
312 312
 
313
-    /**
314
-     * _sort_event_prices_by_type
315
-     *
316
-     * @param EE_Price $price_a
317
-     * @param EE_Price $price_b
318
-     * @return bool false on fail
319
-     */
320
-    public function _sort_event_prices_by_type(EE_Price $price_a, EE_Price $price_b)
321
-    {
322
-        if ($price_a->type_obj()->order() === $price_b->type_obj()->order()) {
323
-            return $this->_sort_event_prices_by_order($price_a, $price_b);
324
-        }
325
-        return $price_a->type_obj()->order() < $price_b->type_obj()->order() ? -1 : 1;
326
-    }
313
+	/**
314
+	 * _sort_event_prices_by_type
315
+	 *
316
+	 * @param EE_Price $price_a
317
+	 * @param EE_Price $price_b
318
+	 * @return bool false on fail
319
+	 */
320
+	public function _sort_event_prices_by_type(EE_Price $price_a, EE_Price $price_b)
321
+	{
322
+		if ($price_a->type_obj()->order() === $price_b->type_obj()->order()) {
323
+			return $this->_sort_event_prices_by_order($price_a, $price_b);
324
+		}
325
+		return $price_a->type_obj()->order() < $price_b->type_obj()->order() ? -1 : 1;
326
+	}
327 327
 
328 328
 
329
-    /**
330
-     *        _sort_event_prices_by_order
331
-     *
332
-     * @param EE_Price $price_a
333
-     * @param EE_Price $price_b
334
-     * @return bool false on fail
335
-     */
336
-    public function _sort_event_prices_by_order(EE_Price $price_a, EE_Price $price_b)
337
-    {
338
-        if ($price_a->order() === $price_b->order()) {
339
-            return 0;
340
-        }
341
-        return $price_a->order() < $price_b->order() ? -1 : 1;
342
-    }
329
+	/**
330
+	 *        _sort_event_prices_by_order
331
+	 *
332
+	 * @param EE_Price $price_a
333
+	 * @param EE_Price $price_b
334
+	 * @return bool false on fail
335
+	 */
336
+	public function _sort_event_prices_by_order(EE_Price $price_a, EE_Price $price_b)
337
+	{
338
+		if ($price_a->order() === $price_b->order()) {
339
+			return 0;
340
+		}
341
+		return $price_a->order() < $price_b->order() ? -1 : 1;
342
+	}
343 343
 
344 344
 
345
-    /**
346
-     * get all prices of a specific type
347
-     *
348
-     * @param int $type - PRT_ID
349
-     * @return EE_Base_Class[]|EE_PRice[]
350
-     * @throws EE_Error
351
-     */
352
-    public function get_all_prices_that_are_type($type = 0)
353
-    {
354
-        return $this->get_all(
355
-            [
356
-                [
357
-                    'PRT_ID' => $type,
358
-                ],
359
-                'order_by' => $this->_order_by_array_for_get_all_method(),
360
-            ]
361
-        );
362
-    }
345
+	/**
346
+	 * get all prices of a specific type
347
+	 *
348
+	 * @param int $type - PRT_ID
349
+	 * @return EE_Base_Class[]|EE_PRice[]
350
+	 * @throws EE_Error
351
+	 */
352
+	public function get_all_prices_that_are_type($type = 0)
353
+	{
354
+		return $this->get_all(
355
+			[
356
+				[
357
+					'PRT_ID' => $type,
358
+				],
359
+				'order_by' => $this->_order_by_array_for_get_all_method(),
360
+			]
361
+		);
362
+	}
363 363
 
364 364
 
365
-    /**
366
-     * Returns an array of the normal 'order_by' query parameter provided to the get_all query.
367
-     * Of course you don't have to use it, but this is the order we usually want to sort prices by
368
-     *
369
-     * @return array which can be used like so: $this->get_all(array(array(...where
370
-     *               stuff...),'order_by'=>$this->_order_by_array_for_get_all_method()));
371
-     */
372
-    public function _order_by_array_for_get_all_method()
373
-    {
374
-        return [
375
-            'PRC_order'            => 'ASC',
376
-            'Price_Type.PRT_order' => 'ASC',
377
-            'PRC_ID'               => 'ASC',
378
-        ];
379
-    }
365
+	/**
366
+	 * Returns an array of the normal 'order_by' query parameter provided to the get_all query.
367
+	 * Of course you don't have to use it, but this is the order we usually want to sort prices by
368
+	 *
369
+	 * @return array which can be used like so: $this->get_all(array(array(...where
370
+	 *               stuff...),'order_by'=>$this->_order_by_array_for_get_all_method()));
371
+	 */
372
+	public function _order_by_array_for_get_all_method()
373
+	{
374
+		return [
375
+			'PRC_order'            => 'ASC',
376
+			'Price_Type.PRT_order' => 'ASC',
377
+			'PRC_ID'               => 'ASC',
378
+		];
379
+	}
380 380
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -115,23 +115,23 @@  discard block
 block discarded – undo
115 115
             'WP_User'    => new EE_Belongs_To_Relation(),
116 116
         ];
117 117
         // this model is generally available for reading
118
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] =
118
+        $this->_cap_restriction_generators[EEM_Base::caps_read] =
119 119
             new EE_Restriction_Generator_Default_Public(
120 120
                 'PRC_is_default',
121 121
                 'Ticket.Datetime.Event'
122 122
             );
123 123
         // account for default tickets in the caps
124
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] =
124
+        $this->_cap_restriction_generators[EEM_Base::caps_read_admin] =
125 125
             new EE_Restriction_Generator_Default_Protected(
126 126
                 'PRC_is_default',
127 127
                 'Ticket.Datetime.Event'
128 128
             );
129
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ]       =
129
+        $this->_cap_restriction_generators[EEM_Base::caps_edit] =
130 130
             new EE_Restriction_Generator_Default_Protected(
131 131
                 'PRC_is_default',
132 132
                 'Ticket.Datetime.Event'
133 133
             );
134
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ]     =
134
+        $this->_cap_restriction_generators[EEM_Base::caps_delete] =
135 135
             new EE_Restriction_Generator_Default_Protected(
136 136
                 'PRC_is_default',
137 137
                 'Ticket.Datetime.Event'
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
             'PRC_deleted'    => 0,
200 200
             'PRC_is_default' => 1,
201 201
         ];
202
-        if (! $include_taxes) {
202
+        if ( ! $include_taxes) {
203 203
             $_where['Price_Type.PBT_ID'] = ['!=', 4];
204 204
         }
205 205
         $_query_params = [
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
         );
257 257
         foreach ($all_taxes as $tax) {
258 258
             if ($tax instanceof EE_Price) {
259
-                $taxes[ $tax->order() ][ $tax->ID() ] = $tax;
259
+                $taxes[$tax->order()][$tax->ID()] = $tax;
260 260
             }
261 261
         }
262 262
         return $taxes;
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
             if ($default_prices) {
282 282
                 foreach ($default_prices as $price) {
283 283
                     if ($price instanceof EE_Price) {
284
-                        $array_of_price_objects[ $price->type() ][] = $price;
284
+                        $array_of_price_objects[$price->type()][] = $price;
285 285
                     }
286 286
                 }
287 287
                 return $array_of_price_objects;
@@ -298,10 +298,10 @@  discard block
 block discarded – undo
298 298
             ]
299 299
         );
300 300
 
301
-        if (! empty($ticket_prices)) {
301
+        if ( ! empty($ticket_prices)) {
302 302
             foreach ($ticket_prices as $price) {
303 303
                 if ($price instanceof EE_Price) {
304
-                    $array_of_price_objects[ $price->type() ][] = $price;
304
+                    $array_of_price_objects[$price->type()][] = $price;
305 305
                 }
306 306
             }
307 307
             return $array_of_price_objects;
Please login to merge, or discard this patch.
core/db_models/fields/EE_Money_Field.php 1 patch
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -9,91 +9,91 @@
 block discarded – undo
9 9
  */
10 10
 class EE_Money_Field extends EE_Float_Field
11 11
 {
12
-    /**
13
-     * @var DecimalValues
14
-     */
15
-    protected $decimal_values;
12
+	/**
13
+	 * @var DecimalValues
14
+	 */
15
+	protected $decimal_values;
16 16
 
17 17
 
18
-    /**
19
-     * @param string $table_column
20
-     * @param string $nicename
21
-     * @param bool   $nullable
22
-     * @param null   $default_value
23
-     * @throws EE_Error
24
-     * @throws ReflectionException
25
-     */
26
-    public function __construct($table_column, $nicename, $nullable, $default_value = null)
27
-    {
28
-        parent::__construct($table_column, $nicename, $nullable, $default_value);
29
-        $this->setSchemaType('object');
30
-        $this->decimal_values = LoaderFactory::getShared(
31
-            'EventEspresso\core\services\helpers\DecimalValues',
32
-            [EE_Currency_Config::getCurrencyConfig()]
33
-        );
34
-    }
18
+	/**
19
+	 * @param string $table_column
20
+	 * @param string $nicename
21
+	 * @param bool   $nullable
22
+	 * @param null   $default_value
23
+	 * @throws EE_Error
24
+	 * @throws ReflectionException
25
+	 */
26
+	public function __construct($table_column, $nicename, $nullable, $default_value = null)
27
+	{
28
+		parent::__construct($table_column, $nicename, $nullable, $default_value);
29
+		$this->setSchemaType('object');
30
+		$this->decimal_values = LoaderFactory::getShared(
31
+			'EventEspresso\core\services\helpers\DecimalValues',
32
+			[EE_Currency_Config::getCurrencyConfig()]
33
+		);
34
+	}
35 35
 
36 36
 
37
-    /**
38
-     * Schemas:
39
-     *    'localized_float': "3,023.00"
40
-     *    'no_currency_code': "$3,023.00"
41
-     *    null: "$3,023.00<span>USD</span>"
42
-     *
43
-     * @param string $value_on_field_to_be_outputted
44
-     * @param string $schema
45
-     * @return string
46
-     */
47
-    public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null): string
48
-    {
49
-        if ($schema == 'localized_float') {
50
-            return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted);
51
-        }
52
-        $display_code = $schema !== 'no_currency_code';
53
-        // we don't use the $pretty_float because format_currency will take care of it.
54
-        return EEH_Template::format_currency($value_on_field_to_be_outputted, false, $display_code);
55
-    }
37
+	/**
38
+	 * Schemas:
39
+	 *    'localized_float': "3,023.00"
40
+	 *    'no_currency_code': "$3,023.00"
41
+	 *    null: "$3,023.00<span>USD</span>"
42
+	 *
43
+	 * @param string $value_on_field_to_be_outputted
44
+	 * @param string $schema
45
+	 * @return string
46
+	 */
47
+	public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null): string
48
+	{
49
+		if ($schema == 'localized_float') {
50
+			return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted);
51
+		}
52
+		$display_code = $schema !== 'no_currency_code';
53
+		// we don't use the $pretty_float because format_currency will take care of it.
54
+		return EEH_Template::format_currency($value_on_field_to_be_outputted, false, $display_code);
55
+	}
56 56
 
57 57
 
58
-    /**
59
-     * If provided with a string, strips out money-related formatting to turn it into a proper float.
60
-     * Rounds the float to the correct number of decimal places for this country's currency.
61
-     * Also, interprets periods and commas according to the country's currency settings.
62
-     * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, call floatval() on it first.
63
-     *
64
-     * @param string $value_inputted_for_field_on_model_object
65
-     * @return float
66
-     */
67
-    public function prepare_for_set($value_inputted_for_field_on_model_object): float
68
-    {
69
-        // now it's a float-style string or number
70
-        $float_val = parent::prepare_for_set($value_inputted_for_field_on_model_object);
71
-        // round to the correctly number of decimal places for this  currency
72
-        return $this->decimal_values->roundDecimalValue($float_val);
73
-    }
58
+	/**
59
+	 * If provided with a string, strips out money-related formatting to turn it into a proper float.
60
+	 * Rounds the float to the correct number of decimal places for this country's currency.
61
+	 * Also, interprets periods and commas according to the country's currency settings.
62
+	 * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, call floatval() on it first.
63
+	 *
64
+	 * @param string $value_inputted_for_field_on_model_object
65
+	 * @return float
66
+	 */
67
+	public function prepare_for_set($value_inputted_for_field_on_model_object): float
68
+	{
69
+		// now it's a float-style string or number
70
+		$float_val = parent::prepare_for_set($value_inputted_for_field_on_model_object);
71
+		// round to the correctly number of decimal places for this  currency
72
+		return $this->decimal_values->roundDecimalValue($float_val);
73
+	}
74 74
 
75 75
 
76
-    /**
77
-     * @return array[]
78
-     */
79
-    public function getSchemaProperties(): array
80
-    {
81
-        return [
82
-            'raw'    => [
83
-                'description' => sprintf(
84
-                    esc_html__('%s - the raw value as it exists in the database as a simple float.', 'event_espresso'),
85
-                    $this->get_nicename()
86
-                ),
87
-                'type'        => 'number',
88
-            ],
89
-            'pretty' => [
90
-                'description' => sprintf(
91
-                    esc_html__('%s - formatted for display in the set currency and decimal places.', 'event_espresso'),
92
-                    $this->get_nicename()
93
-                ),
94
-                'type'        => 'string',
95
-                'format'      => 'money',
96
-            ],
97
-        ];
98
-    }
76
+	/**
77
+	 * @return array[]
78
+	 */
79
+	public function getSchemaProperties(): array
80
+	{
81
+		return [
82
+			'raw'    => [
83
+				'description' => sprintf(
84
+					esc_html__('%s - the raw value as it exists in the database as a simple float.', 'event_espresso'),
85
+					$this->get_nicename()
86
+				),
87
+				'type'        => 'number',
88
+			],
89
+			'pretty' => [
90
+				'description' => sprintf(
91
+					esc_html__('%s - formatted for display in the set currency and decimal places.', 'event_espresso'),
92
+					$this->get_nicename()
93
+				),
94
+				'type'        => 'string',
95
+				'format'      => 'money',
96
+			],
97
+		];
98
+	}
99 99
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_Float_Field.php 1 patch
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -6,78 +6,78 @@
 block discarded – undo
6 6
  */
7 7
 class EE_Float_Field extends EE_Model_Field_Base
8 8
 {
9
-    /**
10
-     * @var EE_Currency_Config
11
-     */
12
-    protected $currency;
9
+	/**
10
+	 * @var EE_Currency_Config
11
+	 */
12
+	protected $currency;
13 13
 
14 14
 
15
-    /**
16
-     * @param string $table_column
17
-     * @param string $nicename
18
-     * @param bool   $nullable
19
-     * @param null   $default_value
20
-     */
21
-    public function __construct($table_column, $nicename, $nullable, $default_value = null)
22
-    {
23
-        $this->currency = EE_Config::instance()->currency;
24
-        parent::__construct($table_column, $nicename, $nullable, $default_value);
25
-        $this->setSchemaType('number');
26
-    }
15
+	/**
16
+	 * @param string $table_column
17
+	 * @param string $nicename
18
+	 * @param bool   $nullable
19
+	 * @param null   $default_value
20
+	 */
21
+	public function __construct($table_column, $nicename, $nullable, $default_value = null)
22
+	{
23
+		$this->currency = EE_Config::instance()->currency;
24
+		parent::__construct($table_column, $nicename, $nullable, $default_value);
25
+		$this->setSchemaType('number');
26
+	}
27 27
 
28 28
 
29
-    /**
30
-     * If provided a string, strips out number-related formatting, like commas, periods, spaces, other junk, etc.
31
-     * However, treats commas and periods as thousand-separators ro decimal marks, as indicate by the config's currency.
32
-     * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, call floatval() on it first.
33
-     * Returns a float
34
-     *
35
-     * @param float|string $value_inputted_for_field_on_model_object
36
-     * @return float
37
-     */
38
-    public function prepare_for_set($value_inputted_for_field_on_model_object)
39
-    {
40
-        // remove whitespaces and thousands separators
41
-        if (is_string($value_inputted_for_field_on_model_object)) {
42
-            $value_inputted_for_field_on_model_object = str_replace(
43
-                array(" ", $this->currency->thsnds),
44
-                "",
45
-                $value_inputted_for_field_on_model_object
46
-            );
47
-            // normalize it so periods are decimal marks (we don't care where you're from: we're talking PHP now)
48
-            $value_inputted_for_field_on_model_object = str_replace(
49
-                $this->currency->dec_mrk,
50
-                ".",
51
-                $value_inputted_for_field_on_model_object
52
-            );
53
-            // double-check there's absolutely nothing left on this string besides numbers
54
-            $value_inputted_for_field_on_model_object = preg_replace(
55
-                "/[^0-9,.]/",
56
-                "",
57
-                $value_inputted_for_field_on_model_object
58
-            );
59
-        }
60
-        return floatval($value_inputted_for_field_on_model_object);
61
-    }
29
+	/**
30
+	 * If provided a string, strips out number-related formatting, like commas, periods, spaces, other junk, etc.
31
+	 * However, treats commas and periods as thousand-separators ro decimal marks, as indicate by the config's currency.
32
+	 * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, call floatval() on it first.
33
+	 * Returns a float
34
+	 *
35
+	 * @param float|string $value_inputted_for_field_on_model_object
36
+	 * @return float
37
+	 */
38
+	public function prepare_for_set($value_inputted_for_field_on_model_object)
39
+	{
40
+		// remove whitespaces and thousands separators
41
+		if (is_string($value_inputted_for_field_on_model_object)) {
42
+			$value_inputted_for_field_on_model_object = str_replace(
43
+				array(" ", $this->currency->thsnds),
44
+				"",
45
+				$value_inputted_for_field_on_model_object
46
+			);
47
+			// normalize it so periods are decimal marks (we don't care where you're from: we're talking PHP now)
48
+			$value_inputted_for_field_on_model_object = str_replace(
49
+				$this->currency->dec_mrk,
50
+				".",
51
+				$value_inputted_for_field_on_model_object
52
+			);
53
+			// double-check there's absolutely nothing left on this string besides numbers
54
+			$value_inputted_for_field_on_model_object = preg_replace(
55
+				"/[^0-9,.]/",
56
+				"",
57
+				$value_inputted_for_field_on_model_object
58
+			);
59
+		}
60
+		return floatval($value_inputted_for_field_on_model_object);
61
+	}
62 62
 
63
-    /**
64
-     * Returns the number formatted according to local custom (set by the country of the blog).
65
-     *
66
-     * @param float $value_on_field_to_be_outputted
67
-     * @return string
68
-     */
69
-    public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
70
-    {
71
-        return number_format(
72
-            $value_on_field_to_be_outputted,
73
-            $this->currency->dec_plc,
74
-            $this->currency->dec_mrk,
75
-            $this->currency->thsnds
76
-        );
77
-    }
63
+	/**
64
+	 * Returns the number formatted according to local custom (set by the country of the blog).
65
+	 *
66
+	 * @param float $value_on_field_to_be_outputted
67
+	 * @return string
68
+	 */
69
+	public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
70
+	{
71
+		return number_format(
72
+			$value_on_field_to_be_outputted,
73
+			$this->currency->dec_plc,
74
+			$this->currency->dec_mrk,
75
+			$this->currency->thsnds
76
+		);
77
+	}
78 78
 
79
-    public function prepare_for_set_from_db($value_found_in_db_for_model_object)
80
-    {
81
-        return floatval($value_found_in_db_for_model_object);
82
-    }
79
+	public function prepare_for_set_from_db($value_found_in_db_for_model_object)
80
+	{
81
+		return floatval($value_found_in_db_for_model_object);
82
+	}
83 83
 }
Please login to merge, or discard this patch.
core/domain/services/admin/registrations/DatetimesForEventCheckIn.php 2 patches
Indentation   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -12,157 +12,157 @@
 block discarded – undo
12 12
 
13 13
 class DatetimesForEventCheckIn
14 14
 {
15
-    /**
16
-     * @var EE_Capabilities $caps
17
-     */
18
-    public $caps;
19
-
20
-    /**
21
-     * @var EE_Event
22
-     */
23
-    protected $event;
24
-
25
-    /**
26
-     * @var EE_Event[]
27
-     */
28
-    protected $all_events;
29
-
30
-    /**
31
-     * @var EE_Datetime[]
32
-     */
33
-    protected $datetimes;
34
-
35
-    /**
36
-     * @var int
37
-     */
38
-    private $start_date_offset;
39
-
40
-
41
-    /**
42
-     * @param EE_Capabilities $capabilities
43
-     * @param EE_Event|null   $event
44
-     */
45
-    public function __construct(EE_Capabilities $capabilities, ?EE_Event $event = null)
46
-    {
47
-        $this->event = $event;
48
-        $this->caps = $capabilities;
49
-        $this->start_date_offset = absint(
50
-            apply_filters(
51
-                'FHEE__EventEspresso_core_domain_services_admin_registrations_DatetimesForEventCheckIn__start_date_offset',
52
-                HOUR_IN_SECONDS * 2,
53
-                $this->event
54
-            )
55
-        );
56
-    }
57
-
58
-
59
-    /**
60
-     * @param int $event_id
61
-     * @return DatetimesForEventCheckIn
62
-     * @throws EE_Error
63
-     * @throws ReflectionException
64
-     */
65
-    public static function fromEventID(int $event_id): DatetimesForEventCheckIn
66
-    {
67
-        /** @var EE_Event $event */
68
-        $event = EEM_Event::instance()->get_one_by_ID($event_id);
69
-        return new DatetimesForEventCheckIn(EE_Capabilities::instance(), $event);
70
-    }
71
-
72
-
73
-    /**
74
-     * @param EE_Event $event
75
-     * @return DatetimesForEventCheckIn
76
-     */
77
-    public static function fromEvent(EE_Event $event): DatetimesForEventCheckIn
78
-    {
79
-        return new DatetimesForEventCheckIn(EE_Capabilities::instance(), $event);
80
-    }
81
-
82
-
83
-    /**
84
-     * @param EE_Registration $registration
85
-     * @return DatetimesForEventCheckIn
86
-     * @throws EE_Error
87
-     */
88
-    public static function fromRegistration(EE_Registration $registration): DatetimesForEventCheckIn
89
-    {
90
-        return new DatetimesForEventCheckIn(EE_Capabilities::instance(), $registration->event());
91
-    }
92
-
93
-
94
-    /**
95
-     * @return EE_Event
96
-     */
97
-    public function event(): EE_Event
98
-    {
99
-        return $this->event;
100
-    }
101
-
102
-
103
-    /**
104
-     * @return array
105
-     * @throws EE_Error
106
-     * @throws ReflectionException
107
-     */
108
-    public function getAllActiveDatetimesForAllEvents(): array
109
-    {
110
-        if ($this->all_events === null) {
111
-            $where = [
112
-                'Registration.REG_ID' => ['!=', null]
113
-            ];
114
-            if (! $this->caps->current_user_can('ee_read_private_events', 'get_events')) {
115
-                $where['status**'] = ['!=', 'private'];
116
-            }
117
-            if (! $this->caps->current_user_can('ee_read_others_events', 'get_events')) {
118
-                $where['EVT_wp_user'] = get_current_user_id();
119
-            }
120
-            $this->all_events = EEM_Event::instance()->get_all(
121
-                [
122
-                    $where,
123
-                    'order_by' => ['Datetime.DTT_EVT_start' => 'DESC'],
124
-                ]
125
-            );
126
-        }
127
-        return $this->all_events;
128
-    }
129
-
130
-
131
-    /**
132
-     * @return array
133
-     * @throws EE_Error
134
-     * @throws ReflectionException
135
-     */
136
-    public function getAllActiveDatetimesForEvent(bool $active = true): array
137
-    {
138
-        $start_date = $active ? time() - $this->start_date_offset : null;
139
-        return $this->event instanceof EE_Event
140
-            ? $this->event->activeDatetimes($start_date)
141
-            : [];
142
-    }
143
-
144
-
145
-    /**
146
-     * @param int|null $DTD_ID If specific datetime ID is supplied, will return that date, but only if it is active.
147
-     *                         If no ID is supplied but event only has one related datetime, then it will be returned.
148
-     *                         If the above conditions are not met, then function will return null.
149
-     * @return EE_Datetime|null
150
-     * @throws EE_Error
151
-     * @throws ReflectionException
152
-     */
153
-    public function getOneActiveDatetimeForEvent(?int $DTD_ID = 0): ?EE_Datetime
154
-    {
155
-        if ($this->datetimes === null) {
156
-            $this->datetimes = $this->getAllActiveDatetimesForEvent();
157
-        }
158
-        if ($DTD_ID) {
159
-            foreach ($this->datetimes as $datetime) {
160
-                if ($datetime instanceof EE_Datetime && $datetime->ID() === $DTD_ID) {
161
-                    return $datetime;
162
-                }
163
-            }
164
-            return null;
165
-        }
166
-        return count($this->datetimes) === 1 ? reset($this->datetimes) : null;
167
-    }
15
+	/**
16
+	 * @var EE_Capabilities $caps
17
+	 */
18
+	public $caps;
19
+
20
+	/**
21
+	 * @var EE_Event
22
+	 */
23
+	protected $event;
24
+
25
+	/**
26
+	 * @var EE_Event[]
27
+	 */
28
+	protected $all_events;
29
+
30
+	/**
31
+	 * @var EE_Datetime[]
32
+	 */
33
+	protected $datetimes;
34
+
35
+	/**
36
+	 * @var int
37
+	 */
38
+	private $start_date_offset;
39
+
40
+
41
+	/**
42
+	 * @param EE_Capabilities $capabilities
43
+	 * @param EE_Event|null   $event
44
+	 */
45
+	public function __construct(EE_Capabilities $capabilities, ?EE_Event $event = null)
46
+	{
47
+		$this->event = $event;
48
+		$this->caps = $capabilities;
49
+		$this->start_date_offset = absint(
50
+			apply_filters(
51
+				'FHEE__EventEspresso_core_domain_services_admin_registrations_DatetimesForEventCheckIn__start_date_offset',
52
+				HOUR_IN_SECONDS * 2,
53
+				$this->event
54
+			)
55
+		);
56
+	}
57
+
58
+
59
+	/**
60
+	 * @param int $event_id
61
+	 * @return DatetimesForEventCheckIn
62
+	 * @throws EE_Error
63
+	 * @throws ReflectionException
64
+	 */
65
+	public static function fromEventID(int $event_id): DatetimesForEventCheckIn
66
+	{
67
+		/** @var EE_Event $event */
68
+		$event = EEM_Event::instance()->get_one_by_ID($event_id);
69
+		return new DatetimesForEventCheckIn(EE_Capabilities::instance(), $event);
70
+	}
71
+
72
+
73
+	/**
74
+	 * @param EE_Event $event
75
+	 * @return DatetimesForEventCheckIn
76
+	 */
77
+	public static function fromEvent(EE_Event $event): DatetimesForEventCheckIn
78
+	{
79
+		return new DatetimesForEventCheckIn(EE_Capabilities::instance(), $event);
80
+	}
81
+
82
+
83
+	/**
84
+	 * @param EE_Registration $registration
85
+	 * @return DatetimesForEventCheckIn
86
+	 * @throws EE_Error
87
+	 */
88
+	public static function fromRegistration(EE_Registration $registration): DatetimesForEventCheckIn
89
+	{
90
+		return new DatetimesForEventCheckIn(EE_Capabilities::instance(), $registration->event());
91
+	}
92
+
93
+
94
+	/**
95
+	 * @return EE_Event
96
+	 */
97
+	public function event(): EE_Event
98
+	{
99
+		return $this->event;
100
+	}
101
+
102
+
103
+	/**
104
+	 * @return array
105
+	 * @throws EE_Error
106
+	 * @throws ReflectionException
107
+	 */
108
+	public function getAllActiveDatetimesForAllEvents(): array
109
+	{
110
+		if ($this->all_events === null) {
111
+			$where = [
112
+				'Registration.REG_ID' => ['!=', null]
113
+			];
114
+			if (! $this->caps->current_user_can('ee_read_private_events', 'get_events')) {
115
+				$where['status**'] = ['!=', 'private'];
116
+			}
117
+			if (! $this->caps->current_user_can('ee_read_others_events', 'get_events')) {
118
+				$where['EVT_wp_user'] = get_current_user_id();
119
+			}
120
+			$this->all_events = EEM_Event::instance()->get_all(
121
+				[
122
+					$where,
123
+					'order_by' => ['Datetime.DTT_EVT_start' => 'DESC'],
124
+				]
125
+			);
126
+		}
127
+		return $this->all_events;
128
+	}
129
+
130
+
131
+	/**
132
+	 * @return array
133
+	 * @throws EE_Error
134
+	 * @throws ReflectionException
135
+	 */
136
+	public function getAllActiveDatetimesForEvent(bool $active = true): array
137
+	{
138
+		$start_date = $active ? time() - $this->start_date_offset : null;
139
+		return $this->event instanceof EE_Event
140
+			? $this->event->activeDatetimes($start_date)
141
+			: [];
142
+	}
143
+
144
+
145
+	/**
146
+	 * @param int|null $DTD_ID If specific datetime ID is supplied, will return that date, but only if it is active.
147
+	 *                         If no ID is supplied but event only has one related datetime, then it will be returned.
148
+	 *                         If the above conditions are not met, then function will return null.
149
+	 * @return EE_Datetime|null
150
+	 * @throws EE_Error
151
+	 * @throws ReflectionException
152
+	 */
153
+	public function getOneActiveDatetimeForEvent(?int $DTD_ID = 0): ?EE_Datetime
154
+	{
155
+		if ($this->datetimes === null) {
156
+			$this->datetimes = $this->getAllActiveDatetimesForEvent();
157
+		}
158
+		if ($DTD_ID) {
159
+			foreach ($this->datetimes as $datetime) {
160
+				if ($datetime instanceof EE_Datetime && $datetime->ID() === $DTD_ID) {
161
+					return $datetime;
162
+				}
163
+			}
164
+			return null;
165
+		}
166
+		return count($this->datetimes) === 1 ? reset($this->datetimes) : null;
167
+	}
168 168
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -111,10 +111,10 @@
 block discarded – undo
111 111
             $where = [
112 112
                 'Registration.REG_ID' => ['!=', null]
113 113
             ];
114
-            if (! $this->caps->current_user_can('ee_read_private_events', 'get_events')) {
114
+            if ( ! $this->caps->current_user_can('ee_read_private_events', 'get_events')) {
115 115
                 $where['status**'] = ['!=', 'private'];
116 116
             }
117
-            if (! $this->caps->current_user_can('ee_read_others_events', 'get_events')) {
117
+            if ( ! $this->caps->current_user_can('ee_read_others_events', 'get_events')) {
118 118
                 $where['EVT_wp_user'] = get_current_user_id();
119 119
             }
120 120
             $this->all_events = EEM_Event::instance()->get_all(
Please login to merge, or discard this patch.
core/domain/services/admin/privacy/export/ExportCheckins.php 1 patch
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -16,112 +16,112 @@
 block discarded – undo
16 16
  */
17 17
 class ExportCheckins implements PersonalDataExporterInterface
18 18
 {
19
-    /**
20
-     * @var EEM_Checkin
21
-     */
22
-    protected $checkin_model;
19
+	/**
20
+	 * @var EEM_Checkin
21
+	 */
22
+	protected $checkin_model;
23 23
 
24
-    /**
25
-     * ExportCheckins constructor.
26
-     *
27
-     * @param EEM_Checkin $checkin_model
28
-     */
29
-    public function __construct(EEM_Checkin $checkin_model)
30
-    {
31
-        $this->checkin_model = $checkin_model;
32
-    }
24
+	/**
25
+	 * ExportCheckins constructor.
26
+	 *
27
+	 * @param EEM_Checkin $checkin_model
28
+	 */
29
+	public function __construct(EEM_Checkin $checkin_model)
30
+	{
31
+		$this->checkin_model = $checkin_model;
32
+	}
33 33
 
34 34
 
35
-    /**
36
-     * Returns data for export.
37
-     *
38
-     * @param string    $email_address ,
39
-     * @param int       $page          starts at 1, not 0
40
-     * @return array {
41
-     * @type array      $data          {
42
-     * @type array {
43
-     * @type string     $group_id      (not translated, same for all exports)
44
-     * @type string     $group_label   (translated string)
45
-     * @type string|int $item_id
46
-     * @type array      $data          {
47
-     * @type array {
48
-     * @type string     $name          what's shown in the left-column of the export row
49
-     * @type string     $value         what's showin the right-column of the export row
50
-     *                                 }
51
-     *                                 }
52
-     *                                 }
53
-     *                                 }
54
-     *                                 }
55
-     */
56
-    public function export($email_address, $page = 1)
57
-    {
58
-        $page_size = 10;
59
-        $checkins = $this->checkin_model->get_all(
60
-            array(
61
-                array(
62
-                    'Registration.Attendee.ATT_email' => $email_address,
63
-                ),
64
-                'limit'      => array(
65
-                    ($page - 1) * $page_size,
66
-                    $page_size,
67
-                ),
68
-                'force_join' => array('Registration.Event'),
69
-            )
70
-        );
35
+	/**
36
+	 * Returns data for export.
37
+	 *
38
+	 * @param string    $email_address ,
39
+	 * @param int       $page          starts at 1, not 0
40
+	 * @return array {
41
+	 * @type array      $data          {
42
+	 * @type array {
43
+	 * @type string     $group_id      (not translated, same for all exports)
44
+	 * @type string     $group_label   (translated string)
45
+	 * @type string|int $item_id
46
+	 * @type array      $data          {
47
+	 * @type array {
48
+	 * @type string     $name          what's shown in the left-column of the export row
49
+	 * @type string     $value         what's showin the right-column of the export row
50
+	 *                                 }
51
+	 *                                 }
52
+	 *                                 }
53
+	 *                                 }
54
+	 *                                 }
55
+	 */
56
+	public function export($email_address, $page = 1)
57
+	{
58
+		$page_size = 10;
59
+		$checkins = $this->checkin_model->get_all(
60
+			array(
61
+				array(
62
+					'Registration.Attendee.ATT_email' => $email_address,
63
+				),
64
+				'limit'      => array(
65
+					($page - 1) * $page_size,
66
+					$page_size,
67
+				),
68
+				'force_join' => array('Registration.Event'),
69
+			)
70
+		);
71 71
 
72
-        if (empty($checkins)) {
73
-            return array(
74
-                'data' => array(),
75
-                'done' => true,
76
-            );
77
-        }
72
+		if (empty($checkins)) {
73
+			return array(
74
+				'data' => array(),
75
+				'done' => true,
76
+			);
77
+		}
78 78
 
79
-        $export_items = array();
80
-        foreach ($checkins as $checkin) {
81
-            $reg = $checkin->get_first_related('Registration');
82
-            if ($reg instanceof EE_Registration) {
83
-                $event_name = $reg->event_name();
84
-            } else {
85
-                $event_name = esc_html__('Unknown', 'event_espresso');
86
-            }
87
-            $export_items[] =
88
-                array(
89
-                    'group_id'    => 'check-ins',
90
-                    'group_label' => esc_html__('Event Check-Ins', 'event_espresso'),
91
-                    'item_id'     => $checkin->ID(),
92
-                    'data'        => array(
93
-                        array(
94
-                            'name'  => esc_html__('Time', 'event_espresso'),
95
-                            'value' => $checkin->get_pretty('CHK_timestamp'),
96
-                        ),
97
-                        array(
98
-                            'name'  => esc_html__('Check in/out', 'event_espresso'),
99
-                            'value' => $checkin->status()
100
-                                ? esc_html__('In', 'event_espresso')
101
-                                : esc_html__('Out', 'event_espresso'),
102
-                        ),
103
-                        array(
104
-                            'name'  => esc_html__('Event', 'event_espresso'),
105
-                            'value' => $event_name,
106
-                        ),
107
-                    ),
108
-                );
109
-        }
110
-        return array(
111
-            'data' => $export_items,
112
-            'done' => true,
113
-        );
114
-    }
79
+		$export_items = array();
80
+		foreach ($checkins as $checkin) {
81
+			$reg = $checkin->get_first_related('Registration');
82
+			if ($reg instanceof EE_Registration) {
83
+				$event_name = $reg->event_name();
84
+			} else {
85
+				$event_name = esc_html__('Unknown', 'event_espresso');
86
+			}
87
+			$export_items[] =
88
+				array(
89
+					'group_id'    => 'check-ins',
90
+					'group_label' => esc_html__('Event Check-Ins', 'event_espresso'),
91
+					'item_id'     => $checkin->ID(),
92
+					'data'        => array(
93
+						array(
94
+							'name'  => esc_html__('Time', 'event_espresso'),
95
+							'value' => $checkin->get_pretty('CHK_timestamp'),
96
+						),
97
+						array(
98
+							'name'  => esc_html__('Check in/out', 'event_espresso'),
99
+							'value' => $checkin->status()
100
+								? esc_html__('In', 'event_espresso')
101
+								: esc_html__('Out', 'event_espresso'),
102
+						),
103
+						array(
104
+							'name'  => esc_html__('Event', 'event_espresso'),
105
+							'value' => $event_name,
106
+						),
107
+					),
108
+				);
109
+		}
110
+		return array(
111
+			'data' => $export_items,
112
+			'done' => true,
113
+		);
114
+	}
115 115
 
116
-    /**
117
-     * Gets the Translated name of this exporter
118
-     *
119
-     * @return string
120
-     */
121
-    public function name()
122
-    {
123
-        return esc_html__('Event Espresso Checkins Exporter', 'event_espresso');
124
-    }
116
+	/**
117
+	 * Gets the Translated name of this exporter
118
+	 *
119
+	 * @return string
120
+	 */
121
+	public function name()
122
+	{
123
+		return esc_html__('Event Espresso Checkins Exporter', 'event_espresso');
124
+	}
125 125
 }
126 126
 // End of file ExportCheckins.php
127 127
 // Location: EventEspresso\core\domain\services\admin\privacy\export/ExportCheckins.php
Please login to merge, or discard this patch.
core/domain/services/custom_post_types/RegisterCustomPostTypes.php 1 patch
Indentation   +295 added lines, -295 removed lines patch added patch discarded remove patch
@@ -18,314 +18,314 @@
 block discarded – undo
18 18
 class RegisterCustomPostTypes
19 19
 {
20 20
 
21
-    /**
22
-     * @var CustomPostTypeDefinitions $custom_post_types
23
-     */
24
-    public $custom_post_types;
21
+	/**
22
+	 * @var CustomPostTypeDefinitions $custom_post_types
23
+	 */
24
+	public $custom_post_types;
25 25
 
26
-    /**
27
-     * @var WP_Post_Type[] $wp_post_types
28
-     */
29
-    public $wp_post_types = array();
26
+	/**
27
+	 * @var WP_Post_Type[] $wp_post_types
28
+	 */
29
+	public $wp_post_types = array();
30 30
 
31 31
 
32
-    /**
33
-     * RegisterCustomPostTypes constructor.
34
-     *
35
-     * @param CustomPostTypeDefinitions $custom_post_types
36
-     */
37
-    public function __construct(CustomPostTypeDefinitions $custom_post_types)
38
-    {
39
-        $this->custom_post_types = $custom_post_types;
40
-    }
32
+	/**
33
+	 * RegisterCustomPostTypes constructor.
34
+	 *
35
+	 * @param CustomPostTypeDefinitions $custom_post_types
36
+	 */
37
+	public function __construct(CustomPostTypeDefinitions $custom_post_types)
38
+	{
39
+		$this->custom_post_types = $custom_post_types;
40
+	}
41 41
 
42 42
 
43
-    /**
44
-     * @return WP_Post_Type[]
45
-     */
46
-    public function getRegisteredCustomPostTypes()
47
-    {
48
-        return $this->wp_post_types;
49
-    }
43
+	/**
44
+	 * @return WP_Post_Type[]
45
+	 */
46
+	public function getRegisteredCustomPostTypes()
47
+	{
48
+		return $this->wp_post_types;
49
+	}
50 50
 
51 51
 
52
-    /**
53
-     * @return void
54
-     * @throws DomainException
55
-     */
56
-    public function registerCustomPostTypes()
57
-    {
58
-        $custom_post_types = $this->custom_post_types->getDefinitions();
59
-        foreach ($custom_post_types as $custom_post_type => $CPT) {
60
-            $this->wp_post_types[ $custom_post_type ] = $this->registerCustomPostType(
61
-                $custom_post_type,
62
-                $CPT['singular_name'],
63
-                $CPT['plural_name'],
64
-                $CPT['singular_slug'],
65
-                $CPT['plural_slug'],
66
-                $CPT['args']
67
-            );
68
-        }
69
-    }
52
+	/**
53
+	 * @return void
54
+	 * @throws DomainException
55
+	 */
56
+	public function registerCustomPostTypes()
57
+	{
58
+		$custom_post_types = $this->custom_post_types->getDefinitions();
59
+		foreach ($custom_post_types as $custom_post_type => $CPT) {
60
+			$this->wp_post_types[ $custom_post_type ] = $this->registerCustomPostType(
61
+				$custom_post_type,
62
+				$CPT['singular_name'],
63
+				$CPT['plural_name'],
64
+				$CPT['singular_slug'],
65
+				$CPT['plural_slug'],
66
+				$CPT['args']
67
+			);
68
+		}
69
+	}
70 70
 
71 71
 
72
-    /**
73
-     * Registers a new custom post type. Sets default settings given only the following params.
74
-     * Returns the registered post type object, or an error object.
75
-     *
76
-     * @param string $post_type          the actual post type name
77
-     *                                   IMPORTANT:
78
-     *                                   this must match what the slug is for admin pages related to this CPT
79
-     *                                   Also any models must use this slug as well
80
-     * @param string $singular_name      a pre-internationalized string for the singular name of the objects
81
-     * @param string $plural_name        a pre-internationalized string for the plural name of the objects
82
-     * @param string $singular_slug
83
-     * @param string $plural_slug
84
-     * @param array  $override_arguments exactly like $args as described in
85
-     *                                   http://codex.wordpress.org/Function_Reference/register_post_type
86
-     * @return WP_Post_Type|WP_Error
87
-     * @throws DomainException
88
-     */
89
-    public function registerCustomPostType(
90
-        $post_type,
91
-        $singular_name,
92
-        $plural_name,
93
-        $singular_slug = '',
94
-        $plural_slug = '',
95
-        array $override_arguments = array()
96
-    ) {
97
-        $wp_post_type = register_post_type(
98
-            $post_type,
99
-            $this->prepareArguments(
100
-                $post_type,
101
-                $singular_name,
102
-                $plural_name,
103
-                $singular_slug,
104
-                $plural_slug,
105
-                $override_arguments
106
-            )
107
-        );
108
-        if ($wp_post_type instanceof WP_Error) {
109
-            throw new DomainException($wp_post_type->get_error_message());
110
-        }
111
-        return $wp_post_type;
112
-    }
72
+	/**
73
+	 * Registers a new custom post type. Sets default settings given only the following params.
74
+	 * Returns the registered post type object, or an error object.
75
+	 *
76
+	 * @param string $post_type          the actual post type name
77
+	 *                                   IMPORTANT:
78
+	 *                                   this must match what the slug is for admin pages related to this CPT
79
+	 *                                   Also any models must use this slug as well
80
+	 * @param string $singular_name      a pre-internationalized string for the singular name of the objects
81
+	 * @param string $plural_name        a pre-internationalized string for the plural name of the objects
82
+	 * @param string $singular_slug
83
+	 * @param string $plural_slug
84
+	 * @param array  $override_arguments exactly like $args as described in
85
+	 *                                   http://codex.wordpress.org/Function_Reference/register_post_type
86
+	 * @return WP_Post_Type|WP_Error
87
+	 * @throws DomainException
88
+	 */
89
+	public function registerCustomPostType(
90
+		$post_type,
91
+		$singular_name,
92
+		$plural_name,
93
+		$singular_slug = '',
94
+		$plural_slug = '',
95
+		array $override_arguments = array()
96
+	) {
97
+		$wp_post_type = register_post_type(
98
+			$post_type,
99
+			$this->prepareArguments(
100
+				$post_type,
101
+				$singular_name,
102
+				$plural_name,
103
+				$singular_slug,
104
+				$plural_slug,
105
+				$override_arguments
106
+			)
107
+		);
108
+		if ($wp_post_type instanceof WP_Error) {
109
+			throw new DomainException($wp_post_type->get_error_message());
110
+		}
111
+		return $wp_post_type;
112
+	}
113 113
 
114 114
 
115
-    /**
116
-     * @param string $post_type          the actual post type name
117
-     * @param string $singular_name      a pre-internationalized string for the singular name of the objects
118
-     * @param string $plural_name        a pre-internationalized string for the plural name of the objects
119
-     * @param string $singular_slug
120
-     * @param string $plural_slug
121
-     * @param array  $override_arguments The default values set in this function will be overridden
122
-     *                                   by whatever you set in $override_arguments
123
-     * @return array
124
-     */
125
-    protected function prepareArguments(
126
-        $post_type,
127
-        $singular_name,
128
-        $plural_name,
129
-        $singular_slug,
130
-        $plural_slug,
131
-        array $override_arguments = array()
132
-    ) {
133
-        // verify plural slug and singular slug, if they aren't we'll use $singular_name and $plural_name
134
-        $singular_slug = ! empty($singular_slug) ? $singular_slug : $singular_name;
135
-        $plural_slug = ! empty($plural_slug) ? $plural_slug : $plural_name;
136
-        $labels = $this->getLabels(
137
-            $singular_name,
138
-            $plural_name,
139
-            $singular_slug,
140
-            $plural_slug
141
-        );
142
-        // note the page_templates arg in the supports index is something specific to EE.
143
-        // WordPress doesn't actually have that in their register_post_type api.
144
-        $arguments = $this->getDefaultArguments($labels, $post_type, $plural_slug);
145
-        if ($override_arguments) {
146
-            if (isset($override_arguments['labels'])) {
147
-                $labels = array_merge($arguments['labels'], $override_arguments['labels']);
148
-            }
149
-            $arguments = array_merge($arguments, $override_arguments);
150
-            $arguments['labels'] = $labels;
151
-        }
152
-        return $arguments;
153
-    }
115
+	/**
116
+	 * @param string $post_type          the actual post type name
117
+	 * @param string $singular_name      a pre-internationalized string for the singular name of the objects
118
+	 * @param string $plural_name        a pre-internationalized string for the plural name of the objects
119
+	 * @param string $singular_slug
120
+	 * @param string $plural_slug
121
+	 * @param array  $override_arguments The default values set in this function will be overridden
122
+	 *                                   by whatever you set in $override_arguments
123
+	 * @return array
124
+	 */
125
+	protected function prepareArguments(
126
+		$post_type,
127
+		$singular_name,
128
+		$plural_name,
129
+		$singular_slug,
130
+		$plural_slug,
131
+		array $override_arguments = array()
132
+	) {
133
+		// verify plural slug and singular slug, if they aren't we'll use $singular_name and $plural_name
134
+		$singular_slug = ! empty($singular_slug) ? $singular_slug : $singular_name;
135
+		$plural_slug = ! empty($plural_slug) ? $plural_slug : $plural_name;
136
+		$labels = $this->getLabels(
137
+			$singular_name,
138
+			$plural_name,
139
+			$singular_slug,
140
+			$plural_slug
141
+		);
142
+		// note the page_templates arg in the supports index is something specific to EE.
143
+		// WordPress doesn't actually have that in their register_post_type api.
144
+		$arguments = $this->getDefaultArguments($labels, $post_type, $plural_slug);
145
+		if ($override_arguments) {
146
+			if (isset($override_arguments['labels'])) {
147
+				$labels = array_merge($arguments['labels'], $override_arguments['labels']);
148
+			}
149
+			$arguments = array_merge($arguments, $override_arguments);
150
+			$arguments['labels'] = $labels;
151
+		}
152
+		return $arguments;
153
+	}
154 154
 
155 155
 
156
-    /**
157
-     * @param string $singular_name
158
-     * @param string $plural_name
159
-     * @param string $singular_slug
160
-     * @param string $plural_slug
161
-     * @return array
162
-     */
163
-    private function getLabels($singular_name, $plural_name, $singular_slug, $plural_slug)
164
-    {
165
-        return array(
166
-            'name'                     => $plural_name,
167
-            'singular_name'            => $singular_name,
168
-            'singular_slug'            => $singular_slug,
169
-            'plural_slug'              => $plural_slug,
170
-            'add_new'                  => sprintf(
171
-                /* Translators: Post Type Label */
172
-                esc_html_x('Add New %s', 'Add New Event', 'event_espresso'),
173
-                $singular_name
174
-            ),
175
-            'add_new_item'             => sprintf(
176
-                /* Translators: Post Type Label */
177
-                esc_html_x('Add New %s', 'Add New Event', 'event_espresso'),
178
-                $singular_name
179
-            ),
180
-            'edit_item'                => sprintf(
181
-                /* Translators: Post Type Label */
182
-                esc_html_x('Edit %s', 'Edit Event', 'event_espresso'),
183
-                $singular_name
184
-            ),
185
-            'new_item'                 => sprintf(
186
-                /* Translators: Post Type Label */
187
-                esc_html_x('New %s', 'New Event', 'event_espresso'),
188
-                $singular_name
189
-            ),
190
-            'all_items'                => sprintf(
191
-                /* Translators: Post Type Label */
192
-                esc_html_x('All %s', 'All Events', 'event_espresso'),
193
-                $plural_name
194
-            ),
195
-            'view_item'                => sprintf(
196
-                /* Translators: Post Type Label */
197
-                esc_html_x('View %s', 'View Event', 'event_espresso'),
198
-                $singular_name
199
-            ),
200
-            'view_items'               => sprintf(
201
-                /* Translators: Post Type Label */
202
-                esc_html_x('View %s', 'View Events', 'event_espresso'),
203
-                $plural_name
204
-            ),
205
-            'archives'                 => sprintf(
206
-                /* Translators: Post Type Label */
207
-                esc_html_x('%s Archives', 'Event Archives', 'event_espresso'),
208
-                $singular_name
209
-            ),
210
-            'attributes'               => sprintf(
211
-                /* Translators: Post Type Label */
212
-                esc_html_x('%s Attributes', 'Event Attributes', 'event_espresso'),
213
-                $singular_name
214
-            ),
215
-            'insert_into_item'         => sprintf(
216
-                /* Translators: Post Type Label */
217
-                esc_html_x('Insert into this %s', 'Insert into this Event', 'event_espresso'),
218
-                $singular_name
219
-            ),
220
-            'uploaded_to_this_item'    => sprintf(
221
-                /* Translators: Post Type Label */
222
-                esc_html_x('Uploaded to this %s', 'Uploaded to this Event', 'event_espresso'),
223
-                $singular_name
224
-            ),
225
-            'filter_items_list'        => sprintf(
226
-                /* Translators: Post Type Label */
227
-                esc_html_x('Filter %s list', 'Filter Events list', 'event_espresso'),
228
-                $plural_name
229
-            ),
230
-            'items_list_navigation'    => sprintf(
231
-                /* Translators: Post Type Label */
232
-                esc_html_x('%s list navigation', 'Events list navigation', 'event_espresso'),
233
-                $plural_name
234
-            ),
235
-            'items_list'               => sprintf(
236
-                /* Translators: Post Type Label */
237
-                esc_html_x('%s list', 'Events list', 'event_espresso'),
238
-                $plural_name
239
-            ),
240
-            'item_published'           => sprintf(
241
-                /* Translators: Post Type Label */
242
-                esc_html_x('%s published', 'Event published', 'event_espresso'),
243
-                $singular_name
244
-            ),
245
-            'item_published_privately' => sprintf(
246
-                /* Translators: Post Type Label */
247
-                esc_html_x('%s published privately', 'Event published privately', 'event_espresso'),
248
-                $singular_name
249
-            ),
250
-            'item_reverted_to_draft'   => sprintf(
251
-                /* Translators: Post Type Label */
252
-                esc_html_x('%s reverted to draft', 'Event reverted to draft', 'event_espresso'),
253
-                $singular_name
254
-            ),
255
-            'item_scheduled'           => sprintf(
256
-                /* Translators: Post Type Label */
257
-                esc_html_x('%s scheduled', 'Event scheduled', 'event_espresso'),
258
-                $singular_name
259
-            ),
260
-            'item_updated'             => sprintf(
261
-                /* Translators: Post Type Label */
262
-                esc_html_x('%s updated', 'Event updated', 'event_espresso'),
263
-                $singular_name
264
-            ),
265
-            'search_items'             => sprintf(
266
-                /* Translators: Post Type Label */
267
-                esc_html_x('Search %s', 'Search Events', 'event_espresso'),
268
-                $plural_name
269
-            ),
270
-            'not_found'                => sprintf(
271
-                /* Translators: Post Type Label */
272
-                esc_html_x('No %s found', 'No Events found', 'event_espresso'),
273
-                $plural_name
274
-            ),
275
-            'not_found_in_trash'       => sprintf(
276
-                /* Translators: Post Type Label */
277
-                esc_html_x('No %s found in Trash', 'No Events found in Trash', 'event_espresso'),
278
-                $plural_name
279
-            ),
280
-            'parent_item_colon'        => '',
281
-            'menu_name'                => $plural_name,
282
-        );
283
-    }
156
+	/**
157
+	 * @param string $singular_name
158
+	 * @param string $plural_name
159
+	 * @param string $singular_slug
160
+	 * @param string $plural_slug
161
+	 * @return array
162
+	 */
163
+	private function getLabels($singular_name, $plural_name, $singular_slug, $plural_slug)
164
+	{
165
+		return array(
166
+			'name'                     => $plural_name,
167
+			'singular_name'            => $singular_name,
168
+			'singular_slug'            => $singular_slug,
169
+			'plural_slug'              => $plural_slug,
170
+			'add_new'                  => sprintf(
171
+				/* Translators: Post Type Label */
172
+				esc_html_x('Add New %s', 'Add New Event', 'event_espresso'),
173
+				$singular_name
174
+			),
175
+			'add_new_item'             => sprintf(
176
+				/* Translators: Post Type Label */
177
+				esc_html_x('Add New %s', 'Add New Event', 'event_espresso'),
178
+				$singular_name
179
+			),
180
+			'edit_item'                => sprintf(
181
+				/* Translators: Post Type Label */
182
+				esc_html_x('Edit %s', 'Edit Event', 'event_espresso'),
183
+				$singular_name
184
+			),
185
+			'new_item'                 => sprintf(
186
+				/* Translators: Post Type Label */
187
+				esc_html_x('New %s', 'New Event', 'event_espresso'),
188
+				$singular_name
189
+			),
190
+			'all_items'                => sprintf(
191
+				/* Translators: Post Type Label */
192
+				esc_html_x('All %s', 'All Events', 'event_espresso'),
193
+				$plural_name
194
+			),
195
+			'view_item'                => sprintf(
196
+				/* Translators: Post Type Label */
197
+				esc_html_x('View %s', 'View Event', 'event_espresso'),
198
+				$singular_name
199
+			),
200
+			'view_items'               => sprintf(
201
+				/* Translators: Post Type Label */
202
+				esc_html_x('View %s', 'View Events', 'event_espresso'),
203
+				$plural_name
204
+			),
205
+			'archives'                 => sprintf(
206
+				/* Translators: Post Type Label */
207
+				esc_html_x('%s Archives', 'Event Archives', 'event_espresso'),
208
+				$singular_name
209
+			),
210
+			'attributes'               => sprintf(
211
+				/* Translators: Post Type Label */
212
+				esc_html_x('%s Attributes', 'Event Attributes', 'event_espresso'),
213
+				$singular_name
214
+			),
215
+			'insert_into_item'         => sprintf(
216
+				/* Translators: Post Type Label */
217
+				esc_html_x('Insert into this %s', 'Insert into this Event', 'event_espresso'),
218
+				$singular_name
219
+			),
220
+			'uploaded_to_this_item'    => sprintf(
221
+				/* Translators: Post Type Label */
222
+				esc_html_x('Uploaded to this %s', 'Uploaded to this Event', 'event_espresso'),
223
+				$singular_name
224
+			),
225
+			'filter_items_list'        => sprintf(
226
+				/* Translators: Post Type Label */
227
+				esc_html_x('Filter %s list', 'Filter Events list', 'event_espresso'),
228
+				$plural_name
229
+			),
230
+			'items_list_navigation'    => sprintf(
231
+				/* Translators: Post Type Label */
232
+				esc_html_x('%s list navigation', 'Events list navigation', 'event_espresso'),
233
+				$plural_name
234
+			),
235
+			'items_list'               => sprintf(
236
+				/* Translators: Post Type Label */
237
+				esc_html_x('%s list', 'Events list', 'event_espresso'),
238
+				$plural_name
239
+			),
240
+			'item_published'           => sprintf(
241
+				/* Translators: Post Type Label */
242
+				esc_html_x('%s published', 'Event published', 'event_espresso'),
243
+				$singular_name
244
+			),
245
+			'item_published_privately' => sprintf(
246
+				/* Translators: Post Type Label */
247
+				esc_html_x('%s published privately', 'Event published privately', 'event_espresso'),
248
+				$singular_name
249
+			),
250
+			'item_reverted_to_draft'   => sprintf(
251
+				/* Translators: Post Type Label */
252
+				esc_html_x('%s reverted to draft', 'Event reverted to draft', 'event_espresso'),
253
+				$singular_name
254
+			),
255
+			'item_scheduled'           => sprintf(
256
+				/* Translators: Post Type Label */
257
+				esc_html_x('%s scheduled', 'Event scheduled', 'event_espresso'),
258
+				$singular_name
259
+			),
260
+			'item_updated'             => sprintf(
261
+				/* Translators: Post Type Label */
262
+				esc_html_x('%s updated', 'Event updated', 'event_espresso'),
263
+				$singular_name
264
+			),
265
+			'search_items'             => sprintf(
266
+				/* Translators: Post Type Label */
267
+				esc_html_x('Search %s', 'Search Events', 'event_espresso'),
268
+				$plural_name
269
+			),
270
+			'not_found'                => sprintf(
271
+				/* Translators: Post Type Label */
272
+				esc_html_x('No %s found', 'No Events found', 'event_espresso'),
273
+				$plural_name
274
+			),
275
+			'not_found_in_trash'       => sprintf(
276
+				/* Translators: Post Type Label */
277
+				esc_html_x('No %s found in Trash', 'No Events found in Trash', 'event_espresso'),
278
+				$plural_name
279
+			),
280
+			'parent_item_colon'        => '',
281
+			'menu_name'                => $plural_name,
282
+		);
283
+	}
284 284
 
285 285
 
286
-    /**
287
-     * @param array  $labels
288
-     * @param string $post_type
289
-     * @param string $plural_slug
290
-     * @return array
291
-     */
292
-    private function getDefaultArguments(array $labels, $post_type, $plural_slug)
293
-    {
294
-        return array(
295
-            'labels'             => $labels,
296
-            'public'             => true,
297
-            'publicly_queryable' => true,
298
-            'show_ui'            => false,
299
-            'show_ee_ui'         => true,
300
-            'show_in_menu'       => false,
301
-            'show_in_nav_menus'  => false,
302
-            'query_var'          => true,
303
-            'rewrite'            => apply_filters(
304
-                'FHEE__EventEspresso_core_domain_entities_custom_post_types_RegisterCustomPostTypes__getDefaultArguments__rewrite',
305
-                // legacy filter applied for now,
306
-                // later on we'll run a has_filter($tag) check and throw a doing_it_wrong() notice
307
-                apply_filters(
308
-                    'FHEE__EE_Register_CPTs__register_CPT__rewrite',
309
-                    array('slug' => $plural_slug),
310
-                    $post_type
311
-                ),
312
-                $post_type,
313
-                $plural_slug
314
-            ),
315
-            'capability_type'    => 'post',
316
-            'map_meta_cap'       => true,
317
-            'has_archive'        => true,
318
-            'hierarchical'       => false,
319
-            'menu_position'      => null,
320
-            'supports'           => array(
321
-                'title',
322
-                'editor',
323
-                'author',
324
-                'thumbnail',
325
-                'excerpt',
326
-                'custom-fields',
327
-                'comments',
328
-            ),
329
-        );
330
-    }
286
+	/**
287
+	 * @param array  $labels
288
+	 * @param string $post_type
289
+	 * @param string $plural_slug
290
+	 * @return array
291
+	 */
292
+	private function getDefaultArguments(array $labels, $post_type, $plural_slug)
293
+	{
294
+		return array(
295
+			'labels'             => $labels,
296
+			'public'             => true,
297
+			'publicly_queryable' => true,
298
+			'show_ui'            => false,
299
+			'show_ee_ui'         => true,
300
+			'show_in_menu'       => false,
301
+			'show_in_nav_menus'  => false,
302
+			'query_var'          => true,
303
+			'rewrite'            => apply_filters(
304
+				'FHEE__EventEspresso_core_domain_entities_custom_post_types_RegisterCustomPostTypes__getDefaultArguments__rewrite',
305
+				// legacy filter applied for now,
306
+				// later on we'll run a has_filter($tag) check and throw a doing_it_wrong() notice
307
+				apply_filters(
308
+					'FHEE__EE_Register_CPTs__register_CPT__rewrite',
309
+					array('slug' => $plural_slug),
310
+					$post_type
311
+				),
312
+				$post_type,
313
+				$plural_slug
314
+			),
315
+			'capability_type'    => 'post',
316
+			'map_meta_cap'       => true,
317
+			'has_archive'        => true,
318
+			'hierarchical'       => false,
319
+			'menu_position'      => null,
320
+			'supports'           => array(
321
+				'title',
322
+				'editor',
323
+				'author',
324
+				'thumbnail',
325
+				'excerpt',
326
+				'custom-fields',
327
+				'comments',
328
+			),
329
+		);
330
+	}
331 331
 }
Please login to merge, or discard this patch.