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_Event 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_Event, and based on these observations, apply Extract Interface, too.
| 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
||
| 14 | class EE_Event extends EE_CPT_Base implements EEI_Line_Item_Object, EEI_Admin_Links, EEI_Has_Icon, EEI_Event |
||
| 15 | { |
||
| 16 | |||
| 17 | /** |
||
| 18 | * cached value for the the logical active status for the event |
||
| 19 | * |
||
| 20 | * @see get_active_status() |
||
| 21 | * @var string |
||
| 22 | */ |
||
| 23 | protected $_active_status = ''; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * This is just used for caching the Primary Datetime for the Event on initial retrieval |
||
| 27 | * |
||
| 28 | * @var EE_Datetime |
||
| 29 | */ |
||
| 30 | protected $_Primary_Datetime; |
||
| 31 | |||
| 32 | |||
| 33 | |||
| 34 | /** |
||
| 35 | * @param array $props_n_values incoming values |
||
| 36 | * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
||
| 37 | * used.) |
||
| 38 | * @param array $date_formats incoming date_formats in an array where the first value is the |
||
| 39 | * date_format and the second value is the time format |
||
| 40 | * @return EE_Event |
||
| 41 | * @throws \EE_Error |
||
| 42 | */ |
||
| 43 | public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
||
| 48 | |||
| 49 | |||
| 50 | |||
| 51 | /** |
||
| 52 | * @param array $props_n_values incoming values from the database |
||
| 53 | * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
||
| 54 | * the website will be used. |
||
| 55 | * @return EE_Event |
||
| 56 | * @throws \EE_Error |
||
| 57 | */ |
||
| 58 | public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
||
| 62 | |||
| 63 | |||
| 64 | |||
| 65 | /** |
||
| 66 | * Overrides parent set() method so that all calls to set( 'status', $status ) can be routed to internal methods |
||
| 67 | * |
||
| 68 | * @param string $field_name |
||
| 69 | * @param mixed $field_value |
||
| 70 | * @param bool $use_default |
||
| 71 | * @throws \EE_Error |
||
| 72 | */ |
||
| 73 | public function set($field_name, $field_value, $use_default = false) |
||
| 83 | |||
| 84 | |||
| 85 | |||
| 86 | /** |
||
| 87 | * set_status |
||
| 88 | * Checks if event status is being changed to SOLD OUT |
||
| 89 | * and updates event meta data with previous event status |
||
| 90 | * so that we can revert things if/when the event is no longer sold out |
||
| 91 | * |
||
| 92 | * @access public |
||
| 93 | * @param string $new_status |
||
| 94 | * @param bool $use_default |
||
| 95 | * @return void |
||
| 96 | * @throws \EE_Error |
||
| 97 | */ |
||
| 98 | public function set_status($new_status = null, $use_default = false) |
||
| 129 | |||
| 130 | |||
| 131 | |||
| 132 | /** |
||
| 133 | * Gets all the datetimes for this event |
||
| 134 | * |
||
| 135 | * @param array $query_params like EEM_Base::get_all |
||
| 136 | * @return EE_Datetime[] |
||
| 137 | * @throws \EE_Error |
||
| 138 | */ |
||
| 139 | public function datetimes($query_params = array()) |
||
| 143 | |||
| 144 | |||
| 145 | |||
| 146 | /** |
||
| 147 | * Gets all the datetimes for this event, ordered by DTT_EVT_start in ascending order |
||
| 148 | * |
||
| 149 | * @return EE_Datetime[] |
||
| 150 | * @throws \EE_Error |
||
| 151 | */ |
||
| 152 | public function datetimes_in_chronological_order() |
||
| 156 | |||
| 157 | |||
| 158 | |||
| 159 | /** |
||
| 160 | * Gets all the datetimes for this event, ordered by the DTT_order on the datetime. |
||
| 161 | * @darren, we should probably UNSET timezone on the EEM_Datetime model |
||
| 162 | * after running our query, so that this timezone isn't set for EVERY query |
||
| 163 | * on EEM_Datetime for the rest of the request, no? |
||
| 164 | * |
||
| 165 | * @param boolean $show_expired whether or not to include expired events |
||
| 166 | * @param boolean $show_deleted whether or not to include deleted events |
||
| 167 | * @param null $limit |
||
| 168 | * @return \EE_Datetime[] |
||
| 169 | * @throws \EE_Error |
||
| 170 | */ |
||
| 171 | public function datetimes_ordered($show_expired = true, $show_deleted = false, $limit = null) |
||
| 180 | |||
| 181 | |||
| 182 | |||
| 183 | /** |
||
| 184 | * Returns one related datetime. Mostly only used by some legacy code. |
||
| 185 | * |
||
| 186 | * @return EE_Datetime |
||
| 187 | * @throws \EE_Error |
||
| 188 | */ |
||
| 189 | public function first_datetime() |
||
| 193 | |||
| 194 | |||
| 195 | |||
| 196 | /** |
||
| 197 | * Returns the 'primary' datetime for the event |
||
| 198 | * |
||
| 199 | * @param bool $try_to_exclude_expired |
||
| 200 | * @param bool $try_to_exclude_deleted |
||
| 201 | * @return EE_Datetime |
||
| 202 | * @throws \EE_Error |
||
| 203 | */ |
||
| 204 | public function primary_datetime($try_to_exclude_expired = true, $try_to_exclude_deleted = true) |
||
| 216 | |||
| 217 | |||
| 218 | |||
| 219 | /** |
||
| 220 | * Gets all the tickets available for purchase of this event |
||
| 221 | * |
||
| 222 | * @param array $query_params like EEM_Base::get_all |
||
| 223 | * @return EE_Ticket[] |
||
| 224 | * @throws \EE_Error |
||
| 225 | */ |
||
| 226 | public function tickets($query_params = array()) |
||
| 247 | |||
| 248 | |||
| 249 | |||
| 250 | /** |
||
| 251 | * get all unexpired untrashed tickets |
||
| 252 | * |
||
| 253 | * @return bool|EE_Ticket[] |
||
| 254 | * @throws EE_Error |
||
| 255 | */ |
||
| 256 | public function active_tickets() |
||
| 265 | |||
| 266 | |||
| 267 | |||
| 268 | /** |
||
| 269 | * @return bool |
||
| 270 | * @throws \EE_Error |
||
| 271 | */ |
||
| 272 | public function additional_limit() |
||
| 276 | |||
| 277 | |||
| 278 | |||
| 279 | /** |
||
| 280 | * @return bool |
||
| 281 | * @throws \EE_Error |
||
| 282 | */ |
||
| 283 | public function allow_overflow() |
||
| 287 | |||
| 288 | |||
| 289 | |||
| 290 | /** |
||
| 291 | * @return bool |
||
| 292 | * @throws \EE_Error |
||
| 293 | */ |
||
| 294 | public function created() |
||
| 298 | |||
| 299 | |||
| 300 | |||
| 301 | /** |
||
| 302 | * @return bool |
||
| 303 | * @throws \EE_Error |
||
| 304 | */ |
||
| 305 | public function description() |
||
| 309 | |||
| 310 | |||
| 311 | |||
| 312 | /** |
||
| 313 | * Runs do_shortcode and wpautop on the description |
||
| 314 | * |
||
| 315 | * @return string of html |
||
| 316 | * @throws \EE_Error |
||
| 317 | */ |
||
| 318 | public function description_filtered() |
||
| 322 | |||
| 323 | |||
| 324 | |||
| 325 | /** |
||
| 326 | * @return bool |
||
| 327 | * @throws \EE_Error |
||
| 328 | */ |
||
| 329 | public function display_description() |
||
| 333 | |||
| 334 | |||
| 335 | |||
| 336 | /** |
||
| 337 | * @return bool |
||
| 338 | * @throws \EE_Error |
||
| 339 | */ |
||
| 340 | public function display_ticket_selector() |
||
| 344 | |||
| 345 | |||
| 346 | |||
| 347 | /** |
||
| 348 | * @return bool |
||
| 349 | * @throws \EE_Error |
||
| 350 | */ |
||
| 351 | public function external_url() |
||
| 355 | |||
| 356 | |||
| 357 | |||
| 358 | /** |
||
| 359 | * @return bool |
||
| 360 | * @throws \EE_Error |
||
| 361 | */ |
||
| 362 | public function member_only() |
||
| 366 | |||
| 367 | |||
| 368 | |||
| 369 | /** |
||
| 370 | * @return bool |
||
| 371 | * @throws \EE_Error |
||
| 372 | */ |
||
| 373 | public function phone() |
||
| 377 | |||
| 378 | |||
| 379 | |||
| 380 | /** |
||
| 381 | * @return bool |
||
| 382 | * @throws \EE_Error |
||
| 383 | */ |
||
| 384 | public function modified() |
||
| 388 | |||
| 389 | |||
| 390 | |||
| 391 | /** |
||
| 392 | * @return bool |
||
| 393 | * @throws \EE_Error |
||
| 394 | */ |
||
| 395 | public function name() |
||
| 399 | |||
| 400 | |||
| 401 | |||
| 402 | /** |
||
| 403 | * @return bool |
||
| 404 | * @throws \EE_Error |
||
| 405 | */ |
||
| 406 | public function order() |
||
| 410 | |||
| 411 | |||
| 412 | |||
| 413 | /** |
||
| 414 | * @return bool|string |
||
| 415 | * @throws \EE_Error |
||
| 416 | */ |
||
| 417 | public function default_registration_status() |
||
| 424 | |||
| 425 | |||
| 426 | |||
| 427 | /** |
||
| 428 | * @param int $num_words |
||
| 429 | * @param null $more |
||
| 430 | * @param bool $not_full_desc |
||
| 431 | * @return bool|string |
||
| 432 | * @throws \EE_Error |
||
| 433 | */ |
||
| 434 | public function short_description($num_words = 55, $more = null, $not_full_desc = false) |
||
| 444 | |||
| 445 | |||
| 446 | |||
| 447 | /** |
||
| 448 | * @return bool |
||
| 449 | * @throws \EE_Error |
||
| 450 | */ |
||
| 451 | public function slug() |
||
| 455 | |||
| 456 | |||
| 457 | |||
| 458 | /** |
||
| 459 | * @return bool |
||
| 460 | * @throws \EE_Error |
||
| 461 | */ |
||
| 462 | public function timezone_string() |
||
| 466 | |||
| 467 | |||
| 468 | |||
| 469 | /** |
||
| 470 | * @return bool |
||
| 471 | * @throws \EE_Error |
||
| 472 | */ |
||
| 473 | public function visible_on() |
||
| 477 | |||
| 478 | |||
| 479 | |||
| 480 | /** |
||
| 481 | * @return int |
||
| 482 | * @throws \EE_Error |
||
| 483 | */ |
||
| 484 | public function wp_user() |
||
| 488 | |||
| 489 | |||
| 490 | |||
| 491 | /** |
||
| 492 | * @return bool |
||
| 493 | * @throws \EE_Error |
||
| 494 | */ |
||
| 495 | public function donations() |
||
| 499 | |||
| 500 | |||
| 501 | |||
| 502 | /** |
||
| 503 | * @param $limit |
||
| 504 | * @throws \EE_Error |
||
| 505 | */ |
||
| 506 | public function set_additional_limit($limit) |
||
| 510 | |||
| 511 | |||
| 512 | |||
| 513 | /** |
||
| 514 | * @param $created |
||
| 515 | * @throws \EE_Error |
||
| 516 | */ |
||
| 517 | public function set_created($created) |
||
| 521 | |||
| 522 | |||
| 523 | |||
| 524 | /** |
||
| 525 | * @param $desc |
||
| 526 | * @throws \EE_Error |
||
| 527 | */ |
||
| 528 | public function set_description($desc) |
||
| 532 | |||
| 533 | |||
| 534 | |||
| 535 | /** |
||
| 536 | * @param $display_desc |
||
| 537 | * @throws \EE_Error |
||
| 538 | */ |
||
| 539 | public function set_display_description($display_desc) |
||
| 543 | |||
| 544 | |||
| 545 | |||
| 546 | /** |
||
| 547 | * @param $display_ticket_selector |
||
| 548 | * @throws \EE_Error |
||
| 549 | */ |
||
| 550 | public function set_display_ticket_selector($display_ticket_selector) |
||
| 554 | |||
| 555 | |||
| 556 | |||
| 557 | /** |
||
| 558 | * @param $external_url |
||
| 559 | * @throws \EE_Error |
||
| 560 | */ |
||
| 561 | public function set_external_url($external_url) |
||
| 565 | |||
| 566 | |||
| 567 | |||
| 568 | /** |
||
| 569 | * @param $member_only |
||
| 570 | * @throws \EE_Error |
||
| 571 | */ |
||
| 572 | public function set_member_only($member_only) |
||
| 576 | |||
| 577 | |||
| 578 | |||
| 579 | /** |
||
| 580 | * @param $event_phone |
||
| 581 | * @throws \EE_Error |
||
| 582 | */ |
||
| 583 | public function set_event_phone($event_phone) |
||
| 587 | |||
| 588 | |||
| 589 | |||
| 590 | /** |
||
| 591 | * @param $modified |
||
| 592 | * @throws \EE_Error |
||
| 593 | */ |
||
| 594 | public function set_modified($modified) |
||
| 598 | |||
| 599 | |||
| 600 | |||
| 601 | /** |
||
| 602 | * @param $name |
||
| 603 | * @throws \EE_Error |
||
| 604 | */ |
||
| 605 | public function set_name($name) |
||
| 609 | |||
| 610 | |||
| 611 | |||
| 612 | /** |
||
| 613 | * @param $order |
||
| 614 | * @throws \EE_Error |
||
| 615 | */ |
||
| 616 | public function set_order($order) |
||
| 620 | |||
| 621 | |||
| 622 | |||
| 623 | /** |
||
| 624 | * @param $short_desc |
||
| 625 | * @throws \EE_Error |
||
| 626 | */ |
||
| 627 | public function set_short_description($short_desc) |
||
| 631 | |||
| 632 | |||
| 633 | |||
| 634 | /** |
||
| 635 | * @param $slug |
||
| 636 | * @throws \EE_Error |
||
| 637 | */ |
||
| 638 | public function set_slug($slug) |
||
| 642 | |||
| 643 | |||
| 644 | |||
| 645 | /** |
||
| 646 | * @param $timezone_string |
||
| 647 | * @throws \EE_Error |
||
| 648 | */ |
||
| 649 | public function set_timezone_string($timezone_string) |
||
| 653 | |||
| 654 | |||
| 655 | |||
| 656 | /** |
||
| 657 | * @param $visible_on |
||
| 658 | * @throws \EE_Error |
||
| 659 | */ |
||
| 660 | public function set_visible_on($visible_on) |
||
| 664 | |||
| 665 | |||
| 666 | |||
| 667 | /** |
||
| 668 | * @param $wp_user |
||
| 669 | * @throws \EE_Error |
||
| 670 | */ |
||
| 671 | public function set_wp_user($wp_user) |
||
| 675 | |||
| 676 | |||
| 677 | |||
| 678 | /** |
||
| 679 | * @param $default_registration_status |
||
| 680 | * @throws \EE_Error |
||
| 681 | */ |
||
| 682 | public function set_default_registration_status($default_registration_status) |
||
| 686 | |||
| 687 | |||
| 688 | |||
| 689 | /** |
||
| 690 | * @param $donations |
||
| 691 | * @throws \EE_Error |
||
| 692 | */ |
||
| 693 | public function set_donations($donations) |
||
| 697 | |||
| 698 | |||
| 699 | |||
| 700 | /** |
||
| 701 | * Adds a venue to this event |
||
| 702 | * |
||
| 703 | * @param EE_Venue /int $venue_id_or_obj |
||
| 704 | * @return EE_Venue |
||
| 705 | * @throws \EE_Error |
||
| 706 | */ |
||
| 707 | public function add_venue($venue_id_or_obj) |
||
| 711 | |||
| 712 | |||
| 713 | |||
| 714 | /** |
||
| 715 | * Removes a venue from the event |
||
| 716 | * |
||
| 717 | * @param EE_Venue /int $venue_id_or_obj |
||
| 718 | * @return EE_Venue |
||
| 719 | * @throws \EE_Error |
||
| 720 | */ |
||
| 721 | public function remove_venue($venue_id_or_obj) |
||
| 725 | |||
| 726 | |||
| 727 | |||
| 728 | /** |
||
| 729 | * Gets all the venues related ot the event. May provide additional $query_params if desired |
||
| 730 | * |
||
| 731 | * @param array $query_params like EEM_Base::get_all's $query_params |
||
| 732 | * @return EE_Venue[] |
||
| 733 | * @throws \EE_Error |
||
| 734 | */ |
||
| 735 | public function venues($query_params = array()) |
||
| 739 | |||
| 740 | |||
| 741 | |||
| 742 | /** |
||
| 743 | * check if event id is present and if event is published |
||
| 744 | * |
||
| 745 | * @access public |
||
| 746 | * @return boolean true yes, false no |
||
| 747 | * @throws \EE_Error |
||
| 748 | */ |
||
| 749 | private function _has_ID_and_is_published() |
||
| 764 | |||
| 765 | |||
| 766 | |||
| 767 | /** |
||
| 768 | * This simply compares the internal dates with NOW and determines if the event is upcoming or not. |
||
| 769 | * |
||
| 770 | * @access public |
||
| 771 | * @return boolean true yes, false no |
||
| 772 | * @throws \EE_Error |
||
| 773 | */ |
||
| 774 | View Code Duplication | public function is_upcoming() |
|
| 800 | |||
| 801 | |||
| 802 | |||
| 803 | /** |
||
| 804 | * @return bool |
||
| 805 | * @throws \EE_Error |
||
| 806 | */ |
||
| 807 | View Code Duplication | public function is_active() |
|
| 833 | |||
| 834 | |||
| 835 | |||
| 836 | /** |
||
| 837 | * @return bool |
||
| 838 | * @throws \EE_Error |
||
| 839 | */ |
||
| 840 | View Code Duplication | public function is_expired() |
|
| 862 | |||
| 863 | |||
| 864 | |||
| 865 | /** |
||
| 866 | * @return bool |
||
| 867 | * @throws \EE_Error |
||
| 868 | */ |
||
| 869 | public function is_inactive() |
||
| 877 | |||
| 878 | |||
| 879 | |||
| 880 | /** |
||
| 881 | * calculate spaces remaining based on "saleable" tickets |
||
| 882 | * |
||
| 883 | * @param array $tickets |
||
| 884 | * @return int |
||
| 885 | * @throws EE_Error |
||
| 886 | */ |
||
| 887 | public function spaces_remaining($tickets = array(), $filtered = true) |
||
| 907 | |||
| 908 | |||
| 909 | /** |
||
| 910 | * perform_sold_out_status_check |
||
| 911 | * checks all of this events's datetime reg_limit - sold values to determine if ANY datetimes have spaces available... |
||
| 912 | * if NOT, then the event status will get toggled to 'sold_out' |
||
| 913 | * |
||
| 914 | * @access public |
||
| 915 | * @return bool return the ACTUAL sold out state. |
||
| 916 | * @throws \EE_Error |
||
| 917 | */ |
||
| 918 | public function perform_sold_out_status_check() |
||
| 946 | |||
| 947 | |||
| 948 | |||
| 949 | /** |
||
| 950 | * This returns the total remaining spaces for sale on this event. |
||
| 951 | * ############################ |
||
| 952 | * VERY IMPORTANT FOR DEVELOPERS: |
||
| 953 | * While included here, this method is still being tested internally, so its signature and behaviour COULD change. |
||
| 954 | * While this comment block is in place, usage is at your own risk and know that it may change in future builds. |
||
| 955 | * ############################ |
||
| 956 | * |
||
| 957 | * @uses EE_Event::total_available_spaces() |
||
| 958 | * @return float|int (EE_INF is returned as float) |
||
| 959 | * @throws \EE_Error |
||
| 960 | */ |
||
| 961 | public function spaces_remaining_for_sale() |
||
| 974 | |||
| 975 | |||
| 976 | |||
| 977 | /** |
||
| 978 | * This returns the total spaces available for an event while considering all the qtys on the tickets and the reg limits |
||
| 979 | * on the datetimes attached to this event. |
||
| 980 | * ############################ |
||
| 981 | * VERY IMPORTANT FOR DEVELOPERS: |
||
| 982 | * While included here, this method is still being tested internally, so its signature and behaviour COULD change. While |
||
| 983 | * this comment block is in place, usage is at your own risk and know that it may change in future builds. |
||
| 984 | * ############################ |
||
| 985 | * Note: by "spaces available" we are not returning how many spaces remain. That is a calculation involving using the value |
||
| 986 | * from this method and subtracting the approved registrations for the event. |
||
| 987 | * |
||
| 988 | * @param bool $current_total_available Whether to consider any tickets that have already sold in our calculation. |
||
| 989 | * If this is false, then we return the most tickets that could ever be sold |
||
| 990 | * for this event with the datetime and tickets setup on the event under optimal |
||
| 991 | * selling conditions. Otherwise we return a live calculation of spaces available |
||
| 992 | * based on tickets sold. Depending on setup and stage of sales, this |
||
| 993 | * may appear to equal remaining tickets. However, the more tickets are |
||
| 994 | * sold out, the more accurate the "live" total is. |
||
| 995 | * @return int|float (Note: if EE_INF is returned its considered a float by PHP) |
||
| 996 | * @throws \EE_Error |
||
| 997 | */ |
||
| 998 | public function total_available_spaces($current_total_available = false) |
||
| 1123 | |||
| 1124 | |||
| 1125 | |||
| 1126 | /** |
||
| 1127 | * Checks if the event is set to sold out |
||
| 1128 | * |
||
| 1129 | * @param bool $actual whether or not to perform calculations to not only figure the |
||
| 1130 | * actual status but also to flip the status if necessary to sold |
||
| 1131 | * out If false, we just check the existing status of the event |
||
| 1132 | * @return boolean |
||
| 1133 | * @throws \EE_Error |
||
| 1134 | */ |
||
| 1135 | public function is_sold_out($actual = false) |
||
| 1143 | |||
| 1144 | |||
| 1145 | |||
| 1146 | /** |
||
| 1147 | * Checks if the event is marked as postponed |
||
| 1148 | * |
||
| 1149 | * @return boolean |
||
| 1150 | */ |
||
| 1151 | public function is_postponed() |
||
| 1155 | |||
| 1156 | |||
| 1157 | |||
| 1158 | /** |
||
| 1159 | * Checks if the event is marked as cancelled |
||
| 1160 | * |
||
| 1161 | * @return boolean |
||
| 1162 | */ |
||
| 1163 | public function is_cancelled() |
||
| 1167 | |||
| 1168 | |||
| 1169 | |||
| 1170 | /** |
||
| 1171 | * Get the logical active status in a hierarchical order for all the datetimes. Note |
||
| 1172 | * Basically, we order the datetimes by EVT_start_date. Then first test on whether the event is published. If its |
||
| 1173 | * NOT published then we test for whether its expired or not. IF it IS published then we test first on whether an |
||
| 1174 | * event has any active dates. If no active dates then we check for any upcoming dates. If no upcoming dates then |
||
| 1175 | * the event is considered expired. |
||
| 1176 | * NOTE: this method does NOT calculate whether the datetimes are sold out when event is published. Sold Out is a status |
||
| 1177 | * set on the EVENT when it is not published and thus is done |
||
| 1178 | * |
||
| 1179 | * @param bool $reset |
||
| 1180 | * @return bool | string - based on EE_Datetime active constants or FALSE if error. |
||
| 1181 | * @throws \EE_Error |
||
| 1182 | */ |
||
| 1183 | public function get_active_status($reset = false) |
||
| 1232 | |||
| 1233 | |||
| 1234 | |||
| 1235 | /** |
||
| 1236 | * pretty_active_status |
||
| 1237 | * |
||
| 1238 | * @access public |
||
| 1239 | * @param boolean $echo whether to return (FALSE), or echo out the result (TRUE) |
||
| 1240 | * @return mixed void|string |
||
| 1241 | * @throws \EE_Error |
||
| 1242 | */ |
||
| 1243 | public function pretty_active_status($echo = true) |
||
| 1257 | |||
| 1258 | |||
| 1259 | |||
| 1260 | /** |
||
| 1261 | * @return bool|int |
||
| 1262 | * @throws \EE_Error |
||
| 1263 | */ |
||
| 1264 | public function get_number_of_tickets_sold() |
||
| 1278 | |||
| 1279 | |||
| 1280 | |||
| 1281 | /** |
||
| 1282 | * This just returns a count of all the registrations for this event |
||
| 1283 | * |
||
| 1284 | * @access public |
||
| 1285 | * @return int |
||
| 1286 | * @throws \EE_Error |
||
| 1287 | */ |
||
| 1288 | public function get_count_of_all_registrations() |
||
| 1292 | |||
| 1293 | |||
| 1294 | |||
| 1295 | /** |
||
| 1296 | * This returns the ticket with the earliest start time that is |
||
| 1297 | * available for this event (across all datetimes attached to the event) |
||
| 1298 | * |
||
| 1299 | * @return EE_Ticket |
||
| 1300 | * @throws \EE_Error |
||
| 1301 | */ |
||
| 1302 | public function get_ticket_with_earliest_start_time() |
||
| 1308 | |||
| 1309 | |||
| 1310 | |||
| 1311 | /** |
||
| 1312 | * This returns the ticket with the latest end time that is available |
||
| 1313 | * for this event (across all datetimes attached to the event) |
||
| 1314 | * |
||
| 1315 | * @return EE_Ticket |
||
| 1316 | * @throws \EE_Error |
||
| 1317 | */ |
||
| 1318 | public function get_ticket_with_latest_end_time() |
||
| 1324 | |||
| 1325 | |||
| 1326 | |||
| 1327 | /** |
||
| 1328 | * This returns whether there are any tickets on sale for this event. |
||
| 1329 | * |
||
| 1330 | * @return bool true = YES tickets on sale. |
||
| 1331 | * @throws \EE_Error |
||
| 1332 | */ |
||
| 1333 | public function tickets_on_sale() |
||
| 1346 | |||
| 1347 | |||
| 1348 | |||
| 1349 | /** |
||
| 1350 | * Gets the URL for viewing this event on the front-end. Overrides parent |
||
| 1351 | * to check for an external URL first |
||
| 1352 | * |
||
| 1353 | * @return string |
||
| 1354 | * @throws \EE_Error |
||
| 1355 | */ |
||
| 1356 | public function get_permalink() |
||
| 1364 | |||
| 1365 | |||
| 1366 | |||
| 1367 | /** |
||
| 1368 | * Gets the first term for 'espresso_event_categories' we can find |
||
| 1369 | * |
||
| 1370 | * @param array $query_params like EEM_Base::get_all |
||
| 1371 | * @return EE_Term |
||
| 1372 | * @throws \EE_Error |
||
| 1373 | */ |
||
| 1374 | public function first_event_category($query_params = array()) |
||
| 1380 | |||
| 1381 | |||
| 1382 | |||
| 1383 | /** |
||
| 1384 | * Gets all terms for 'espresso_event_categories' we can find |
||
| 1385 | * |
||
| 1386 | * @param array $query_params |
||
| 1387 | * @return EE_Term[] |
||
| 1388 | * @throws \EE_Error |
||
| 1389 | */ |
||
| 1390 | public function get_all_event_categories($query_params = array()) |
||
| 1396 | |||
| 1397 | |||
| 1398 | |||
| 1399 | /** |
||
| 1400 | * Gets all the question groups, ordering them by QSG_order ascending |
||
| 1401 | * |
||
| 1402 | * @param array $query_params @see EEM_Base::get_all |
||
| 1403 | * @return EE_Question_Group[] |
||
| 1404 | * @throws \EE_Error |
||
| 1405 | */ |
||
| 1406 | public function question_groups($query_params = array()) |
||
| 1411 | |||
| 1412 | |||
| 1413 | |||
| 1414 | /** |
||
| 1415 | * Implementation for EEI_Has_Icon interface method. |
||
| 1416 | * |
||
| 1417 | * @see EEI_Visual_Representation for comments |
||
| 1418 | * @return string |
||
| 1419 | */ |
||
| 1420 | public function get_icon() |
||
| 1424 | |||
| 1425 | |||
| 1426 | |||
| 1427 | /** |
||
| 1428 | * Implementation for EEI_Admin_Links interface method. |
||
| 1429 | * |
||
| 1430 | * @see EEI_Admin_Links for comments |
||
| 1431 | * @return string |
||
| 1432 | * @throws \EE_Error |
||
| 1433 | */ |
||
| 1434 | public function get_admin_details_link() |
||
| 1438 | |||
| 1439 | |||
| 1440 | |||
| 1441 | /** |
||
| 1442 | * Implementation for EEI_Admin_Links interface method. |
||
| 1443 | * |
||
| 1444 | * @see EEI_Admin_Links for comments |
||
| 1445 | * @return string |
||
| 1446 | * @throws \EE_Error |
||
| 1447 | */ |
||
| 1448 | public function get_admin_edit_link() |
||
| 1458 | |||
| 1459 | |||
| 1460 | |||
| 1461 | /** |
||
| 1462 | * Implementation for EEI_Admin_Links interface method. |
||
| 1463 | * |
||
| 1464 | * @see EEI_Admin_Links for comments |
||
| 1465 | * @return string |
||
| 1466 | */ |
||
| 1467 | public function get_admin_settings_link() |
||
| 1476 | |||
| 1477 | |||
| 1478 | |||
| 1479 | /** |
||
| 1480 | * Implementation for EEI_Admin_Links interface method. |
||
| 1481 | * |
||
| 1482 | * @see EEI_Admin_Links for comments |
||
| 1483 | * @return string |
||
| 1484 | */ |
||
| 1485 | public function get_admin_overview_link() |
||
| 1494 | |||
| 1495 | } |
||
| 1496 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.