Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like EE_Registration often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use EE_Registration, and based on these observations, apply Extract Interface, too.
1 | <?php use EventEspresso\core\exceptions\EntityNotFoundException; |
||
13 | class EE_Registration extends EE_Soft_Delete_Base_Class implements EEI_Registration, EEI_Admin_Links { |
||
14 | |||
15 | |||
16 | /** |
||
17 | * Used to reference when a registration has never been checked in. |
||
18 | * @type int |
||
19 | */ |
||
20 | const checkin_status_never = 2; |
||
21 | |||
22 | /** |
||
23 | * Used to reference when a registration has been checked in. |
||
24 | * @type int |
||
25 | */ |
||
26 | const checkin_status_in = 1; |
||
27 | |||
28 | |||
29 | /** |
||
30 | * Used to reference when a registration has been checked out. |
||
31 | * @type int |
||
32 | */ |
||
33 | const checkin_status_out = 0; |
||
34 | |||
35 | |||
36 | /** |
||
37 | * extra meta key for tracking reg status os trashed registrations |
||
38 | * |
||
39 | * @type string |
||
40 | */ |
||
41 | const PRE_TRASH_REG_STATUS_KEY = 'pre_trash_registration_status'; |
||
42 | |||
43 | |||
44 | /** |
||
45 | * extra meta key for tracking if registration has reserved ticket |
||
46 | * |
||
47 | * @type string |
||
48 | */ |
||
49 | const HAS_RESERVED_TICKET_KEY = 'has_reserved_ticket'; |
||
50 | |||
51 | |||
52 | |||
53 | /** |
||
54 | * |
||
55 | * @param array $props_n_values incoming values |
||
56 | * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
||
57 | * used.) |
||
58 | * @param array $date_formats incoming date_formats in an array where the first value is the |
||
59 | * date_format and the second value is the time format |
||
60 | * @return EE_Registration |
||
61 | */ |
||
62 | public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
||
66 | |||
67 | |||
68 | |||
69 | /** |
||
70 | * @param array $props_n_values incoming values from the database |
||
71 | * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
||
72 | * the website will be used. |
||
73 | * @return EE_Registration |
||
74 | */ |
||
75 | public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
||
78 | |||
79 | |||
80 | |||
81 | /** |
||
82 | * Set Event ID |
||
83 | * |
||
84 | * @param int $EVT_ID Event ID |
||
85 | */ |
||
86 | public function set_event( $EVT_ID = 0 ) { |
||
89 | |||
90 | |||
91 | |||
92 | /** |
||
93 | * Overrides parent set() method so that all calls to set( 'REG_code', $REG_code ) OR set( 'STS_ID', $STS_ID ) can be routed to internal methods |
||
94 | * |
||
95 | * @param string $field_name |
||
96 | * @param mixed $field_value |
||
97 | * @param bool $use_default |
||
98 | * @throws \EE_Error |
||
99 | * @throws \RuntimeException |
||
100 | */ |
||
101 | public function set( $field_name, $field_value, $use_default = FALSE ) { |
||
115 | |||
116 | |||
117 | |||
118 | /** |
||
119 | * Set Status ID |
||
120 | * updates the registration status and ALSO... |
||
121 | * calls reserve_registration_space() if the reg status changes TO approved from any other reg status |
||
122 | * calls release_registration_space() if the reg status changes FROM approved to any other reg status |
||
123 | * |
||
124 | * @param string $new_STS_ID |
||
125 | * @param boolean $use_default |
||
126 | * @return bool |
||
127 | * @throws \RuntimeException |
||
128 | * @throws \EE_Error |
||
129 | */ |
||
130 | public function set_status( $new_STS_ID = NULL, $use_default = FALSE ) { |
||
167 | |||
168 | |||
169 | |||
170 | /** |
||
171 | * update REGs and TXN when cancelled or declined registrations involved |
||
172 | * |
||
173 | * @param string $new_STS_ID |
||
174 | * @param string $old_STS_ID |
||
175 | * @throws \EE_Error |
||
176 | */ |
||
177 | private function _update_if_canceled_or_declined($new_STS_ID, $old_STS_ID) |
||
225 | |||
226 | |||
227 | /** |
||
228 | * get Status ID |
||
229 | */ |
||
230 | public function status_ID() { |
||
233 | |||
234 | |||
235 | |||
236 | /** |
||
237 | * increments this registration's related ticket sold and corresponding datetime sold values |
||
238 | * |
||
239 | * @return void |
||
240 | * @throws \EE_Error |
||
241 | */ |
||
242 | private function _reserve_registration_space() { |
||
252 | |||
253 | |||
254 | |||
255 | /** |
||
256 | * Gets the ticket this registration is for |
||
257 | * |
||
258 | * @param boolean $include_archived whether to include archived tickets or not. |
||
259 | * @return EE_Ticket|EE_Base_Class |
||
260 | * @throws \EE_Error |
||
261 | */ |
||
262 | public function ticket( $include_archived = TRUE ) { |
||
269 | |||
270 | |||
271 | |||
272 | /** |
||
273 | * Gets the event this registration is for |
||
274 | * @return EE_Event |
||
275 | */ |
||
276 | public function event() { |
||
283 | |||
284 | |||
285 | |||
286 | /** |
||
287 | * Gets the "author" of the registration. Note that for the purposes of registrations, the author will correspond with the author of the event this registration is for. |
||
288 | * |
||
289 | * @since 4.5.0 |
||
290 | * |
||
291 | * @return int |
||
292 | */ |
||
293 | public function wp_user() { |
||
300 | |||
301 | |||
302 | |||
303 | /** |
||
304 | * decrements (subtracts) this registration's related ticket sold and corresponding datetime sold values |
||
305 | * |
||
306 | * @return void |
||
307 | * @throws \EE_Error |
||
308 | */ |
||
309 | private function _release_registration_space() { |
||
314 | |||
315 | |||
316 | |||
317 | /** |
||
318 | * tracks this registration's ticket reservation in extra meta |
||
319 | * and can increment related ticket reserved and corresponding datetime reserved values |
||
320 | * |
||
321 | * @param bool $update_ticket if true, will increment ticket and datetime reserved count |
||
322 | * @return void |
||
323 | * @throws \EE_Error |
||
324 | */ |
||
325 | public function reserve_ticket($update_ticket = false) { |
||
326 | if ($this->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) === false) { |
||
327 | // PLZ NOTE: although checking $update_ticket first would be more efficient, |
||
328 | // we NEED to ALWAYS call update_extra_meta(), which is why that is done first |
||
329 | if ($this->update_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) && $update_ticket) { |
||
330 | $ticket = $this->ticket(); |
||
331 | $ticket->increase_reserved(); |
||
332 | $ticket->save(); |
||
333 | } |
||
334 | } |
||
335 | } |
||
336 | |||
337 | |||
338 | |||
339 | /** |
||
340 | * stops tracking this registration's ticket reservation in extra meta |
||
341 | * decrements (subtracts) related ticket reserved and corresponding datetime reserved values |
||
342 | * |
||
343 | * @param bool $update_ticket if true, will decrement ticket and datetime reserved count |
||
344 | * @return void |
||
345 | * @throws \EE_Error |
||
346 | */ |
||
347 | public function release_reserved_ticket($update_ticket = false) { |
||
348 | if ($this->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) !== false) { |
||
349 | // PLZ NOTE: although checking $update_ticket first would be more efficient, |
||
350 | // we NEED to ALWAYS call delete_extra_meta(), which is why that is done first |
||
351 | if ($this->delete_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY) && $update_ticket) { |
||
352 | $ticket = $this->ticket(); |
||
353 | $ticket->decrease_reserved(); |
||
354 | $ticket->save(); |
||
355 | } |
||
356 | } |
||
357 | } |
||
358 | |||
359 | |||
360 | |||
361 | /** |
||
362 | * Set Attendee ID |
||
363 | * |
||
364 | * @param int $ATT_ID Attendee ID |
||
365 | */ |
||
366 | public function set_attendee_id( $ATT_ID = 0 ) { |
||
369 | |||
370 | |||
371 | |||
372 | /** |
||
373 | * Set Transaction ID |
||
374 | * |
||
375 | * @param int $TXN_ID Transaction ID |
||
376 | */ |
||
377 | public function set_transaction_id( $TXN_ID = 0 ) { |
||
380 | |||
381 | |||
382 | |||
383 | /** |
||
384 | * Set Session |
||
385 | * |
||
386 | * @param string $REG_session PHP Session ID |
||
387 | */ |
||
388 | public function set_session( $REG_session = '' ) { |
||
391 | |||
392 | |||
393 | |||
394 | /** |
||
395 | * Set Registration URL Link |
||
396 | * |
||
397 | * @param string $REG_url_link Registration URL Link |
||
398 | */ |
||
399 | public function set_reg_url_link( $REG_url_link = '' ) { |
||
402 | |||
403 | |||
404 | |||
405 | /** |
||
406 | * Set Attendee Counter |
||
407 | * |
||
408 | * @param int $REG_count Primary Attendee |
||
409 | */ |
||
410 | public function set_count( $REG_count = 1 ) { |
||
413 | |||
414 | |||
415 | |||
416 | /** |
||
417 | * Set Group Size |
||
418 | * |
||
419 | * @param boolean $REG_group_size Group Registration |
||
420 | */ |
||
421 | public function set_group_size( $REG_group_size = FALSE ) { |
||
424 | |||
425 | |||
426 | |||
427 | /** |
||
428 | * is_not_approved - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_not_approved |
||
429 | * |
||
430 | * @return boolean |
||
431 | */ |
||
432 | public function is_not_approved() { |
||
435 | |||
436 | |||
437 | |||
438 | /** |
||
439 | * is_pending_payment - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_pending_payment |
||
440 | * |
||
441 | * @return boolean |
||
442 | */ |
||
443 | public function is_pending_payment() { |
||
446 | |||
447 | |||
448 | |||
449 | /** |
||
450 | * is_approved - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_approved |
||
451 | * |
||
452 | * @return boolean |
||
453 | */ |
||
454 | public function is_approved() { |
||
457 | |||
458 | |||
459 | |||
460 | /** |
||
461 | * is_cancelled - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_cancelled |
||
462 | * |
||
463 | * @return boolean |
||
464 | */ |
||
465 | public function is_cancelled() { |
||
468 | |||
469 | |||
470 | |||
471 | /** |
||
472 | * is_declined - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_declined |
||
473 | * |
||
474 | * @return boolean |
||
475 | */ |
||
476 | public function is_declined() { |
||
479 | |||
480 | |||
481 | |||
482 | /** |
||
483 | * is_incomplete - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_incomplete |
||
484 | * |
||
485 | * @return boolean |
||
486 | */ |
||
487 | public function is_incomplete() { |
||
490 | |||
491 | |||
492 | |||
493 | /** |
||
494 | * Set Registration Date |
||
495 | * |
||
496 | * @param mixed ( int or string ) $REG_date Registration Date - Unix timestamp or string representation of Date |
||
497 | */ |
||
498 | public function set_reg_date( $REG_date = FALSE ) { |
||
501 | |||
502 | |||
503 | |||
504 | /** |
||
505 | * Set final price owing for this registration after all ticket/price modifications |
||
506 | * |
||
507 | * @access public |
||
508 | * @param float $REG_final_price |
||
509 | */ |
||
510 | public function set_final_price( $REG_final_price = 0.00 ) { |
||
513 | |||
514 | |||
515 | |||
516 | /** |
||
517 | * Set amount paid towards this registration's final price |
||
518 | * |
||
519 | * @access public |
||
520 | * @param float $REG_paid |
||
521 | */ |
||
522 | public function set_paid( $REG_paid = 0.00 ) { |
||
525 | |||
526 | |||
527 | |||
528 | /** |
||
529 | * Attendee Is Going |
||
530 | * |
||
531 | * @param boolean $REG_att_is_going Attendee Is Going |
||
532 | */ |
||
533 | public function set_att_is_going( $REG_att_is_going = FALSE ) { |
||
536 | |||
537 | |||
538 | |||
539 | /** |
||
540 | * Gets the related attendee |
||
541 | * @return EE_Attendee |
||
542 | */ |
||
543 | public function attendee() { |
||
546 | |||
547 | |||
548 | |||
549 | /** |
||
550 | * get Event ID |
||
551 | */ |
||
552 | public function event_ID() { |
||
555 | |||
556 | |||
557 | |||
558 | /** |
||
559 | * get Event ID |
||
560 | */ |
||
561 | public function event_name() { |
||
569 | |||
570 | |||
571 | |||
572 | /** |
||
573 | * Fetches the event this registration is for |
||
574 | * @return EE_Event |
||
575 | */ |
||
576 | public function event_obj() { |
||
579 | |||
580 | |||
581 | |||
582 | /** |
||
583 | * get Attendee ID |
||
584 | */ |
||
585 | public function attendee_ID() { |
||
588 | |||
589 | |||
590 | |||
591 | /** |
||
592 | * get PHP Session ID |
||
593 | */ |
||
594 | public function session_ID() { |
||
597 | |||
598 | |||
599 | |||
600 | /** |
||
601 | * Gets the string which represents the URL trigger for the receipt template in the message template system. |
||
602 | * @param string $messenger 'pdf' or 'html'. Default 'html'. |
||
603 | * @return string |
||
604 | */ |
||
605 | public function receipt_url( $messenger = 'html' ) { |
||
620 | |||
621 | |||
622 | |||
623 | |||
624 | /** |
||
625 | * Gets the string which represents the URL trigger for the invoice template in the message template system. |
||
626 | * @param string $messenger 'pdf' or 'html'. Default 'html'. |
||
627 | * @return string |
||
628 | */ |
||
629 | public function invoice_url( $messenger = 'html' ) { |
||
652 | |||
653 | |||
654 | |||
655 | /** |
||
656 | * get Registration URL Link |
||
657 | * |
||
658 | * @access public |
||
659 | * @return string |
||
660 | * @throws \EE_Error |
||
661 | */ |
||
662 | public function reg_url_link() { |
||
665 | |||
666 | |||
667 | |||
668 | /** |
||
669 | * Echoes out invoice_url() |
||
670 | * @param string $type 'download','launch', or 'html' (default is 'launch') |
||
671 | * @return void |
||
672 | */ |
||
673 | public function e_invoice_url( $type = 'launch' ) { |
||
676 | |||
677 | |||
678 | |||
679 | /** |
||
680 | * Echoes out payment_overview_url |
||
681 | */ |
||
682 | public function e_payment_overview_url() { |
||
685 | |||
686 | |||
687 | |||
688 | /** |
||
689 | * Gets the URL of the thank you page with this registration REG_url_link added as |
||
690 | * a query parameter |
||
691 | * @return string |
||
692 | */ |
||
693 | public function payment_overview_url() { |
||
696 | |||
697 | |||
698 | |||
699 | /** |
||
700 | * Gets the URL of the thank you page with this registration REG_url_link added as |
||
701 | * a query parameter |
||
702 | * @return string |
||
703 | */ |
||
704 | public function edit_attendee_information_url() { |
||
707 | |||
708 | |||
709 | |||
710 | /** |
||
711 | * Simply generates and returns the appropriate admin_url link to edit this registration |
||
712 | * @return string |
||
713 | */ |
||
714 | public function get_admin_edit_url() { |
||
717 | |||
718 | |||
719 | |||
720 | /** |
||
721 | * is_primary_registrant? |
||
722 | */ |
||
723 | public function is_primary_registrant() { |
||
726 | |||
727 | |||
728 | |||
729 | /** |
||
730 | * This returns the primary registration object for this registration group (which may be this object). |
||
731 | * @return EE_Registration |
||
732 | */ |
||
733 | public function get_primary_registration() { |
||
741 | |||
742 | |||
743 | |||
744 | /** |
||
745 | * get Attendee Number |
||
746 | * @access public |
||
747 | */ |
||
748 | public function count() { |
||
751 | |||
752 | |||
753 | |||
754 | /** |
||
755 | * get Group Size |
||
756 | */ |
||
757 | public function group_size() { |
||
760 | |||
761 | |||
762 | |||
763 | /** |
||
764 | * get Registration Date |
||
765 | */ |
||
766 | public function date() { |
||
769 | |||
770 | |||
771 | |||
772 | /** |
||
773 | * gets a pretty date |
||
774 | * @param string $date_format |
||
775 | * @param string $time_format |
||
776 | * @return string |
||
777 | */ |
||
778 | public function pretty_date( $date_format = NULL, $time_format = NULL ) { |
||
781 | |||
782 | |||
783 | |||
784 | /** |
||
785 | * final_price |
||
786 | * the registration's share of the transaction total, so that the |
||
787 | * sum of all the transaction's REG_final_prices equal the transaction's total |
||
788 | * @return float |
||
789 | */ |
||
790 | public function final_price() { |
||
793 | |||
794 | |||
795 | |||
796 | /** |
||
797 | * pretty_final_price |
||
798 | * final price as formatted string, with correct decimal places and currency symbol |
||
799 | * @return string |
||
800 | */ |
||
801 | public function pretty_final_price() { |
||
804 | |||
805 | |||
806 | |||
807 | /** |
||
808 | * get paid (yeah) |
||
809 | * @return float |
||
810 | */ |
||
811 | public function paid() { |
||
814 | |||
815 | |||
816 | |||
817 | /** |
||
818 | * pretty_paid |
||
819 | * @return float |
||
820 | */ |
||
821 | public function pretty_paid() { |
||
824 | |||
825 | |||
826 | |||
827 | /** |
||
828 | * owes_monies_and_can_pay |
||
829 | * whether or not this registration has monies owing and it's' status allows payment |
||
830 | * @param array $requires_payment |
||
831 | * @return bool |
||
832 | */ |
||
833 | public function owes_monies_and_can_pay( $requires_payment = array()) { |
||
846 | |||
847 | |||
848 | |||
849 | /** |
||
850 | * Prints out the return value of $this->pretty_status() |
||
851 | * @param bool $show_icons |
||
852 | * @return void |
||
853 | */ |
||
854 | public function e_pretty_status( $show_icons = FALSE ) { |
||
857 | |||
858 | |||
859 | |||
860 | |||
861 | /** |
||
862 | * Returns a nice version of the status for displaying to customers |
||
863 | * @param bool $show_icons |
||
864 | * @return string |
||
865 | */ |
||
866 | public function pretty_status( $show_icons = FALSE ) { |
||
894 | |||
895 | |||
896 | |||
897 | /** |
||
898 | * get Attendee Is Going |
||
899 | */ |
||
900 | public function att_is_going() { |
||
903 | |||
904 | |||
905 | |||
906 | /** |
||
907 | * Gets related answers |
||
908 | * @param array $query_params like EEM_Base::get_all |
||
909 | * @return EE_Answer[] |
||
910 | */ |
||
911 | public function answers( $query_params = NULL ) { |
||
914 | |||
915 | |||
916 | |||
917 | /** |
||
918 | * Gets the registration's answer value to the specified question |
||
919 | * (either the question's ID or a question object) |
||
920 | * @param EE_Question|int $question |
||
921 | * @param bool $pretty_value |
||
922 | * @return array|string if pretty_value= true, the result will always be a string |
||
923 | * (because the answer might be an array of answer values, so passing pretty_value=true |
||
924 | * will convert it into some kind of string) |
||
925 | */ |
||
926 | public function answer_value_to_question( $question, $pretty_value=true ) { |
||
930 | |||
931 | |||
932 | |||
933 | /** |
||
934 | * question_groups |
||
935 | * returns an array of EE_Question_Group objects for this registration |
||
936 | * |
||
937 | * @return EE_Question_Group[] |
||
938 | */ |
||
939 | public function question_groups() { |
||
953 | |||
954 | |||
955 | |||
956 | /** |
||
957 | * count_question_groups |
||
958 | * returns a count of the number of EE_Question_Group objects for this registration |
||
959 | * |
||
960 | * @return int |
||
961 | */ |
||
962 | public function count_question_groups() { |
||
976 | |||
977 | |||
978 | |||
979 | /** |
||
980 | * Returns the registration date in the 'standard' string format |
||
981 | * (function may be improved in the future to allow for different formats and timezones) |
||
982 | * @return string |
||
983 | */ |
||
984 | public function reg_date() { |
||
987 | |||
988 | |||
989 | |||
990 | /** |
||
991 | * Gets the datetime-ticket for this registration (ie, it can be used to isolate |
||
992 | * the ticket this registration purchased, or the datetime they have registered |
||
993 | * to attend) |
||
994 | * @return EE_Datetime_Ticket |
||
995 | */ |
||
996 | public function datetime_ticket() { |
||
999 | |||
1000 | |||
1001 | |||
1002 | /** |
||
1003 | * Sets the registration's datetime_ticket. |
||
1004 | * @param EE_Datetime_Ticket $datetime_ticket |
||
1005 | * @return EE_Datetime_Ticket |
||
1006 | */ |
||
1007 | public function set_datetime_ticket( $datetime_ticket ) { |
||
1010 | /** |
||
1011 | * Gets deleted |
||
1012 | * @return boolean |
||
1013 | */ |
||
1014 | public function deleted() { |
||
1017 | |||
1018 | /** |
||
1019 | * Sets deleted |
||
1020 | * @param boolean $deleted |
||
1021 | * @return boolean |
||
1022 | */ |
||
1023 | public function set_deleted($deleted) { |
||
1030 | |||
1031 | |||
1032 | |||
1033 | /** |
||
1034 | * Get the status object of this object |
||
1035 | * @return EE_Status |
||
1036 | */ |
||
1037 | public function status_obj() { |
||
1040 | |||
1041 | |||
1042 | |||
1043 | /** |
||
1044 | * Returns the number of times this registration has checked into any of the datetimes |
||
1045 | * its available for |
||
1046 | * @return int |
||
1047 | */ |
||
1048 | public function count_checkins() { |
||
1051 | |||
1052 | |||
1053 | |||
1054 | /** |
||
1055 | * Returns the number of current Check-ins this registration is checked into for any of the datetimes the registration is for. Note, this is ONLY checked in (does not include checkedout) |
||
1056 | * @return int |
||
1057 | */ |
||
1058 | public function count_checkins_not_checkedout() { |
||
1061 | |||
1062 | |||
1063 | |||
1064 | /** |
||
1065 | * The purpose of this method is simply to check whether this registration can checkin to the given datetime. |
||
1066 | * |
||
1067 | * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
||
1068 | * @param bool $check_approved This is used to indicate whether the caller wants can_checkin to also consider registration status as well as datetime access. |
||
1069 | * |
||
1070 | * @return bool |
||
1071 | */ |
||
1072 | public function can_checkin( $DTT_OR_ID, $check_approved = TRUE ) { |
||
1087 | |||
1088 | |||
1089 | /** |
||
1090 | * This method verifies whether the user can checkin for the given datetime considering the max uses value set on the ticket. |
||
1091 | * |
||
1092 | * To do this, a query is done to get the count of the datetime records already checked into. If the datetime given does |
||
1093 | * not have a check-in record and checking in for that datetime will exceed the allowed uses, then return false. Otherwise return true. |
||
1094 | * |
||
1095 | * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
||
1096 | * @return bool true means can checkin. false means cannot checkin. |
||
1097 | */ |
||
1098 | public function verify_can_checkin_against_TKT_uses( $DTT_OR_ID ) { |
||
1130 | |||
1131 | |||
1132 | |||
1133 | /** |
||
1134 | * toggle Check-in status for this registration |
||
1135 | * Check-ins are toggled in the following order: |
||
1136 | * never checked in -> checked in |
||
1137 | * checked in -> checked out |
||
1138 | * checked out -> checked in |
||
1139 | * |
||
1140 | * @param int $DTT_ID include specific datetime to toggle Check-in for. |
||
1141 | * If not included or null, then it is assumed latest datetime is being toggled. |
||
1142 | * @param bool $verify If true then can_checkin() is used to verify whether the person |
||
1143 | * can be checked in or not. Otherwise this forces change in checkin status. |
||
1144 | * @return bool|int the chk_in status toggled to OR false if nothing got changed. |
||
1145 | * @throws EE_Error |
||
1146 | */ |
||
1147 | public function toggle_checkin_status( $DTT_ID = null, $verify = false ) { |
||
1200 | |||
1201 | |||
1202 | |||
1203 | /** |
||
1204 | * Returns the latest datetime related to this registration (via the ticket attached to the registration). |
||
1205 | * "Latest" is defined by the `DTT_EVT_start` column. |
||
1206 | * |
||
1207 | * @return EE_Datetime|null |
||
1208 | * @throws \EE_Error |
||
1209 | */ |
||
1210 | View Code Duplication | public function get_latest_related_datetime() { |
|
1220 | |||
1221 | |||
1222 | |||
1223 | /** |
||
1224 | * Returns the earliest datetime related to this registration (via the ticket attached to the registration). |
||
1225 | * "Earliest" is defined by the `DTT_EVT_start` column. |
||
1226 | * |
||
1227 | * @throws \EE_Error |
||
1228 | */ |
||
1229 | View Code Duplication | public function get_earliest_related_datetime() { |
|
1239 | |||
1240 | |||
1241 | |||
1242 | /** |
||
1243 | * This method simply returns the check-in status for this registration and the given datetime. |
||
1244 | * If neither the datetime nor the checkin values are provided as arguments, |
||
1245 | * then this will return the LATEST check-in status for the registration across all datetimes it belongs to. |
||
1246 | * |
||
1247 | * @param int $DTT_ID The ID of the datetime we're checking against |
||
1248 | * (if empty we'll get the primary datetime for |
||
1249 | * this registration (via event) and use it's ID); |
||
1250 | * @param EE_Checkin $checkin If present, we use the given checkin object rather than the dtt_id. |
||
1251 | * @return int Integer representing Check-in status. |
||
1252 | * @throws \EE_Error |
||
1253 | */ |
||
1254 | public function check_in_status_for_datetime( $DTT_ID = 0, $checkin = null ) { |
||
1275 | |||
1276 | |||
1277 | |||
1278 | /** |
||
1279 | * This method returns a localized message for the toggled Check-in message. |
||
1280 | * @param int $DTT_ID include specific datetime to get the correct Check-in message. If not included or null, then it is assumed Check-in for primary datetime was toggled. |
||
1281 | * @param bool $error This just flags that you want an error message returned. This is put in so that the error message can be customized with the attendee name. |
||
1282 | * @return string internationalized message |
||
1283 | */ |
||
1284 | public function get_checkin_msg( $DTT_ID, $error = FALSE ) { |
||
1307 | |||
1308 | |||
1309 | |||
1310 | /** |
||
1311 | * Returns the related EE_Transaction to this registration |
||
1312 | * @return EE_Transaction |
||
1313 | */ |
||
1314 | public function transaction() { |
||
1321 | |||
1322 | |||
1323 | |||
1324 | |||
1325 | /** |
||
1326 | * get Registration Code |
||
1327 | */ |
||
1328 | public function reg_code() { |
||
1331 | |||
1332 | |||
1333 | |||
1334 | /** |
||
1335 | * get Transaction ID |
||
1336 | */ |
||
1337 | public function transaction_ID() { |
||
1340 | |||
1341 | |||
1342 | |||
1343 | /** |
||
1344 | * @return int |
||
1345 | */ |
||
1346 | public function ticket_ID() { |
||
1349 | |||
1350 | |||
1351 | |||
1352 | /** |
||
1353 | * Set Registration Code |
||
1354 | * |
||
1355 | * @access public |
||
1356 | * @param string $REG_code Registration Code |
||
1357 | * @param boolean $use_default |
||
1358 | */ |
||
1359 | public function set_reg_code( $REG_code, $use_default = FALSE ) { |
||
1374 | |||
1375 | |||
1376 | |||
1377 | |||
1378 | /** |
||
1379 | * Returns all other registrations in the same group as this registrant who have the same ticket option. |
||
1380 | * |
||
1381 | * Note, if you want to just get all registrations in the same transaction (group), use: |
||
1382 | * $registration->transaction()->registrations(); |
||
1383 | * |
||
1384 | * @since 4.5.0 |
||
1385 | * |
||
1386 | * @return EE_Registration[] or empty array if this isn't a group registration. |
||
1387 | */ |
||
1388 | public function get_all_other_registrations_in_group() { |
||
1402 | |||
1403 | /** |
||
1404 | * Return the link to the admin details for the object. |
||
1405 | * @return string |
||
1406 | */ |
||
1407 | View Code Duplication | public function get_admin_details_link() { |
|
1418 | |||
1419 | /** |
||
1420 | * Returns the link to the editor for the object. Sometimes this is the same as the details. |
||
1421 | * @return string |
||
1422 | */ |
||
1423 | public function get_admin_edit_link() { |
||
1426 | |||
1427 | /** |
||
1428 | * Returns the link to a settings page for the object. |
||
1429 | * @return string |
||
1430 | */ |
||
1431 | public function get_admin_settings_link() { |
||
1434 | |||
1435 | /** |
||
1436 | * Returns the link to the "overview" for the object (typically the "list table" view). |
||
1437 | * @return string |
||
1438 | */ |
||
1439 | public function get_admin_overview_link() { |
||
1448 | |||
1449 | |||
1450 | |||
1451 | /** |
||
1452 | * @param array $query_params |
||
1453 | * @return \EE_Registration[] |
||
1454 | * @throws \EE_Error |
||
1455 | */ |
||
1456 | public function payments( $query_params = array() ) { |
||
1459 | |||
1460 | |||
1461 | |||
1462 | /** |
||
1463 | * @param array $query_params |
||
1464 | * @return \EE_Registration_Payment[] |
||
1465 | * @throws \EE_Error |
||
1466 | */ |
||
1467 | public function registration_payments( $query_params = array() ) { |
||
1470 | |||
1471 | |||
1472 | |||
1473 | |||
1474 | /** |
||
1475 | * This grabs the payment method corresponding to the last payment made for the amount owing on the registration. |
||
1476 | * Note: if there are no payments on the registration there will be no payment method returned. |
||
1477 | * |
||
1478 | * @return EE_Payment_Method|null |
||
1479 | */ |
||
1480 | public function payment_method() { |
||
1483 | |||
1484 | |||
1485 | |||
1486 | /** |
||
1487 | * @return \EE_Line_Item |
||
1488 | * @throws EntityNotFoundException |
||
1489 | * @throws \EE_Error |
||
1490 | */ |
||
1491 | public function ticket_line_item() |
||
1516 | |||
1517 | |||
1518 | |||
1519 | /** |
||
1520 | * Soft Deletes this model object. |
||
1521 | * |
||
1522 | * @return boolean | int |
||
1523 | * @throws \RuntimeException |
||
1524 | * @throws \EE_Error |
||
1525 | */ |
||
1526 | public function delete() |
||
1533 | |||
1534 | |||
1535 | |||
1536 | /** |
||
1537 | * Restores whatever the previous status was on a registration before it was trashed (if possible) |
||
1538 | * |
||
1539 | * @throws \EE_Error |
||
1540 | * @throws \RuntimeException |
||
1541 | */ |
||
1542 | public function restore() |
||
1555 | |||
1556 | |||
1557 | |||
1558 | /*************************** DEPRECATED ***************************/ |
||
1559 | |||
1560 | |||
1561 | |||
1562 | /** |
||
1563 | * @deprecated |
||
1564 | * @since 4.7.0 |
||
1565 | * @access public |
||
1566 | */ |
||
1567 | public function price_paid() |
||
1574 | |||
1575 | |||
1576 | |||
1577 | /** |
||
1578 | * @deprecated |
||
1579 | * @since 4.7.0 |
||
1580 | * @access public |
||
1581 | * @param float $REG_final_price |
||
1582 | */ |
||
1583 | public function set_price_paid($REG_final_price = 0.00) |
||
1590 | |||
1591 | |||
1592 | |||
1593 | /** |
||
1594 | * @deprecated |
||
1595 | * @since 4.7.0 |
||
1596 | * @return string |
||
1597 | */ |
||
1598 | public function pretty_price_paid() |
||
1605 | |||
1606 | |||
1607 | |||
1608 | /** |
||
1609 | * Gets the primary datetime related to this registration via the related Event to this registration |
||
1610 | * |
||
1611 | * @deprecated 4.9.17 |
||
1612 | * @return EE_Datetime |
||
1613 | */ |
||
1614 | public function get_related_primary_datetime() { |
||
1626 | |||
1627 | |||
1628 | |||
1629 | } |
||
1630 | /* End of file EE_Registration.class.php */ |
||
1632 |
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.