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 |
||
| 13 | class EE_Event extends EE_CPT_Base implements EEI_Line_Item_Object, EEI_Admin_Links, EEI_Has_Icon, EEI_Event |
||
| 14 | { |
||
| 15 | |||
| 16 | /** |
||
| 17 | * cached value for the the logical active status for the event |
||
| 18 | * |
||
| 19 | * @see get_active_status() |
||
| 20 | * @var string |
||
| 21 | */ |
||
| 22 | protected $_active_status = ''; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * This is just used for caching the Primary Datetime for the Event on initial retrieval |
||
| 26 | * |
||
| 27 | * @var EE_Datetime |
||
| 28 | */ |
||
| 29 | protected $_Primary_Datetime; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @var EventSpacesCalculator $available_spaces_calculator |
||
| 33 | */ |
||
| 34 | protected $available_spaces_calculator; |
||
| 35 | |||
| 36 | |||
| 37 | /** |
||
| 38 | * @param array $props_n_values incoming values |
||
| 39 | * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
||
| 40 | * used.) |
||
| 41 | * @param array $date_formats incoming date_formats in an array where the first value is the |
||
| 42 | * date_format and the second value is the time format |
||
| 43 | * @return EE_Event |
||
| 44 | * @throws EE_Error |
||
| 45 | */ |
||
| 46 | public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
||
| 51 | |||
| 52 | |||
| 53 | /** |
||
| 54 | * @param array $props_n_values incoming values from the database |
||
| 55 | * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
||
| 56 | * the website will be used. |
||
| 57 | * @return EE_Event |
||
| 58 | * @throws EE_Error |
||
| 59 | */ |
||
| 60 | public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
||
| 64 | |||
| 65 | |||
| 66 | /** |
||
| 67 | * @return EventSpacesCalculator |
||
| 68 | * @throws \EE_Error |
||
| 69 | */ |
||
| 70 | public function getAvailableSpacesCalculator() |
||
| 77 | |||
| 78 | |||
| 79 | /** |
||
| 80 | * Overrides parent set() method so that all calls to set( 'status', $status ) can be routed to internal methods |
||
| 81 | * |
||
| 82 | * @param string $field_name |
||
| 83 | * @param mixed $field_value |
||
| 84 | * @param bool $use_default |
||
| 85 | * @throws EE_Error |
||
| 86 | */ |
||
| 87 | public function set($field_name, $field_value, $use_default = false) |
||
| 97 | |||
| 98 | |||
| 99 | /** |
||
| 100 | * set_status |
||
| 101 | * Checks if event status is being changed to SOLD OUT |
||
| 102 | * and updates event meta data with previous event status |
||
| 103 | * so that we can revert things if/when the event is no longer sold out |
||
| 104 | * |
||
| 105 | * @access public |
||
| 106 | * @param string $new_status |
||
| 107 | * @param bool $use_default |
||
| 108 | * @return void |
||
| 109 | * @throws EE_Error |
||
| 110 | */ |
||
| 111 | public function set_status($new_status = null, $use_default = false) |
||
| 142 | |||
| 143 | |||
| 144 | /** |
||
| 145 | * Gets all the datetimes for this event |
||
| 146 | * |
||
| 147 | * @param array $query_params like EEM_Base::get_all |
||
| 148 | * @return EE_Base_Class[]|EE_Datetime[] |
||
| 149 | * @throws EE_Error |
||
| 150 | */ |
||
| 151 | public function datetimes($query_params = array()) |
||
| 155 | |||
| 156 | |||
| 157 | /** |
||
| 158 | * Gets all the datetimes for this event, ordered by DTT_EVT_start in ascending order |
||
| 159 | * |
||
| 160 | * @return EE_Base_Class[]|EE_Datetime[] |
||
| 161 | * @throws EE_Error |
||
| 162 | */ |
||
| 163 | public function datetimes_in_chronological_order() |
||
| 167 | |||
| 168 | |||
| 169 | /** |
||
| 170 | * Gets all the datetimes for this event, ordered by the DTT_order on the datetime. |
||
| 171 | * @darren, we should probably UNSET timezone on the EEM_Datetime model |
||
| 172 | * after running our query, so that this timezone isn't set for EVERY query |
||
| 173 | * on EEM_Datetime for the rest of the request, no? |
||
| 174 | * |
||
| 175 | * @param boolean $show_expired whether or not to include expired events |
||
| 176 | * @param boolean $show_deleted whether or not to include deleted events |
||
| 177 | * @param null $limit |
||
| 178 | * @return EE_Datetime[] |
||
| 179 | * @throws EE_Error |
||
| 180 | */ |
||
| 181 | public function datetimes_ordered($show_expired = true, $show_deleted = false, $limit = null) |
||
| 190 | |||
| 191 | |||
| 192 | /** |
||
| 193 | * Returns one related datetime. Mostly only used by some legacy code. |
||
| 194 | * |
||
| 195 | * @return EE_Base_Class|EE_Datetime |
||
| 196 | * @throws EE_Error |
||
| 197 | */ |
||
| 198 | public function first_datetime() |
||
| 202 | |||
| 203 | |||
| 204 | /** |
||
| 205 | * Returns the 'primary' datetime for the event |
||
| 206 | * |
||
| 207 | * @param bool $try_to_exclude_expired |
||
| 208 | * @param bool $try_to_exclude_deleted |
||
| 209 | * @return EE_Datetime |
||
| 210 | * @throws EE_Error |
||
| 211 | */ |
||
| 212 | public function primary_datetime($try_to_exclude_expired = true, $try_to_exclude_deleted = true) |
||
| 224 | |||
| 225 | |||
| 226 | /** |
||
| 227 | * Gets all the tickets available for purchase of this event |
||
| 228 | * |
||
| 229 | * @param array $query_params like EEM_Base::get_all |
||
| 230 | * @return EE_Base_Class[]|EE_Ticket[] |
||
| 231 | * @throws EE_Error |
||
| 232 | */ |
||
| 233 | public function tickets($query_params = array()) |
||
| 254 | |||
| 255 | |||
| 256 | /** |
||
| 257 | * get all unexpired untrashed tickets |
||
| 258 | * |
||
| 259 | * @return EE_Ticket[] |
||
| 260 | * @throws EE_Error |
||
| 261 | */ |
||
| 262 | public function active_tickets() |
||
| 273 | |||
| 274 | |||
| 275 | /** |
||
| 276 | * @return bool |
||
| 277 | * @throws EE_Error |
||
| 278 | */ |
||
| 279 | public function additional_limit() |
||
| 283 | |||
| 284 | |||
| 285 | /** |
||
| 286 | * @return bool |
||
| 287 | * @throws EE_Error |
||
| 288 | */ |
||
| 289 | public function allow_overflow() |
||
| 293 | |||
| 294 | |||
| 295 | /** |
||
| 296 | * @return bool |
||
| 297 | * @throws EE_Error |
||
| 298 | */ |
||
| 299 | public function created() |
||
| 303 | |||
| 304 | |||
| 305 | /** |
||
| 306 | * @return bool |
||
| 307 | * @throws EE_Error |
||
| 308 | */ |
||
| 309 | public function description() |
||
| 313 | |||
| 314 | |||
| 315 | /** |
||
| 316 | * Runs do_shortcode and wpautop on the description |
||
| 317 | * |
||
| 318 | * @return string of html |
||
| 319 | * @throws EE_Error |
||
| 320 | */ |
||
| 321 | public function description_filtered() |
||
| 325 | |||
| 326 | |||
| 327 | /** |
||
| 328 | * @return bool |
||
| 329 | * @throws EE_Error |
||
| 330 | */ |
||
| 331 | public function display_description() |
||
| 335 | |||
| 336 | |||
| 337 | /** |
||
| 338 | * @return bool |
||
| 339 | * @throws EE_Error |
||
| 340 | */ |
||
| 341 | public function display_ticket_selector() |
||
| 345 | |||
| 346 | |||
| 347 | /** |
||
| 348 | * @return bool |
||
| 349 | * @throws EE_Error |
||
| 350 | */ |
||
| 351 | public function external_url() |
||
| 355 | |||
| 356 | |||
| 357 | /** |
||
| 358 | * @return bool |
||
| 359 | * @throws EE_Error |
||
| 360 | */ |
||
| 361 | public function member_only() |
||
| 365 | |||
| 366 | |||
| 367 | /** |
||
| 368 | * @return bool |
||
| 369 | * @throws EE_Error |
||
| 370 | */ |
||
| 371 | public function phone() |
||
| 375 | |||
| 376 | |||
| 377 | /** |
||
| 378 | * @return bool |
||
| 379 | * @throws EE_Error |
||
| 380 | */ |
||
| 381 | public function modified() |
||
| 385 | |||
| 386 | |||
| 387 | /** |
||
| 388 | * @return bool |
||
| 389 | * @throws EE_Error |
||
| 390 | */ |
||
| 391 | public function name() |
||
| 395 | |||
| 396 | |||
| 397 | /** |
||
| 398 | * @return bool |
||
| 399 | * @throws EE_Error |
||
| 400 | */ |
||
| 401 | public function order() |
||
| 405 | |||
| 406 | |||
| 407 | /** |
||
| 408 | * @return bool|string |
||
| 409 | * @throws EE_Error |
||
| 410 | */ |
||
| 411 | public function default_registration_status() |
||
| 418 | |||
| 419 | |||
| 420 | /** |
||
| 421 | * @param int $num_words |
||
| 422 | * @param null $more |
||
| 423 | * @param bool $not_full_desc |
||
| 424 | * @return bool|string |
||
| 425 | * @throws EE_Error |
||
| 426 | */ |
||
| 427 | public function short_description($num_words = 55, $more = null, $not_full_desc = false) |
||
| 436 | |||
| 437 | |||
| 438 | /** |
||
| 439 | * @return bool |
||
| 440 | * @throws EE_Error |
||
| 441 | */ |
||
| 442 | public function slug() |
||
| 446 | |||
| 447 | |||
| 448 | /** |
||
| 449 | * @return bool |
||
| 450 | * @throws EE_Error |
||
| 451 | */ |
||
| 452 | public function timezone_string() |
||
| 456 | |||
| 457 | |||
| 458 | /** |
||
| 459 | * @return bool |
||
| 460 | * @throws EE_Error |
||
| 461 | */ |
||
| 462 | public function visible_on() |
||
| 466 | |||
| 467 | |||
| 468 | /** |
||
| 469 | * @return int |
||
| 470 | * @throws EE_Error |
||
| 471 | */ |
||
| 472 | public function wp_user() |
||
| 476 | |||
| 477 | |||
| 478 | /** |
||
| 479 | * @return bool |
||
| 480 | * @throws EE_Error |
||
| 481 | */ |
||
| 482 | public function donations() |
||
| 486 | |||
| 487 | |||
| 488 | /** |
||
| 489 | * @param $limit |
||
| 490 | * @throws EE_Error |
||
| 491 | */ |
||
| 492 | public function set_additional_limit($limit) |
||
| 496 | |||
| 497 | |||
| 498 | /** |
||
| 499 | * @param $created |
||
| 500 | * @throws EE_Error |
||
| 501 | */ |
||
| 502 | public function set_created($created) |
||
| 506 | |||
| 507 | |||
| 508 | /** |
||
| 509 | * @param $desc |
||
| 510 | * @throws EE_Error |
||
| 511 | */ |
||
| 512 | public function set_description($desc) |
||
| 516 | |||
| 517 | |||
| 518 | /** |
||
| 519 | * @param $display_desc |
||
| 520 | * @throws EE_Error |
||
| 521 | */ |
||
| 522 | public function set_display_description($display_desc) |
||
| 526 | |||
| 527 | |||
| 528 | /** |
||
| 529 | * @param $display_ticket_selector |
||
| 530 | * @throws EE_Error |
||
| 531 | */ |
||
| 532 | public function set_display_ticket_selector($display_ticket_selector) |
||
| 536 | |||
| 537 | |||
| 538 | /** |
||
| 539 | * @param $external_url |
||
| 540 | * @throws EE_Error |
||
| 541 | */ |
||
| 542 | public function set_external_url($external_url) |
||
| 546 | |||
| 547 | |||
| 548 | /** |
||
| 549 | * @param $member_only |
||
| 550 | * @throws EE_Error |
||
| 551 | */ |
||
| 552 | public function set_member_only($member_only) |
||
| 556 | |||
| 557 | |||
| 558 | /** |
||
| 559 | * @param $event_phone |
||
| 560 | * @throws EE_Error |
||
| 561 | */ |
||
| 562 | public function set_event_phone($event_phone) |
||
| 566 | |||
| 567 | |||
| 568 | /** |
||
| 569 | * @param $modified |
||
| 570 | * @throws EE_Error |
||
| 571 | */ |
||
| 572 | public function set_modified($modified) |
||
| 576 | |||
| 577 | |||
| 578 | /** |
||
| 579 | * @param $name |
||
| 580 | * @throws EE_Error |
||
| 581 | */ |
||
| 582 | public function set_name($name) |
||
| 586 | |||
| 587 | |||
| 588 | /** |
||
| 589 | * @param $order |
||
| 590 | * @throws EE_Error |
||
| 591 | */ |
||
| 592 | public function set_order($order) |
||
| 596 | |||
| 597 | |||
| 598 | /** |
||
| 599 | * @param $short_desc |
||
| 600 | * @throws EE_Error |
||
| 601 | */ |
||
| 602 | public function set_short_description($short_desc) |
||
| 606 | |||
| 607 | |||
| 608 | /** |
||
| 609 | * @param $slug |
||
| 610 | * @throws EE_Error |
||
| 611 | */ |
||
| 612 | public function set_slug($slug) |
||
| 616 | |||
| 617 | |||
| 618 | /** |
||
| 619 | * @param $timezone_string |
||
| 620 | * @throws EE_Error |
||
| 621 | */ |
||
| 622 | public function set_timezone_string($timezone_string) |
||
| 626 | |||
| 627 | |||
| 628 | /** |
||
| 629 | * @param $visible_on |
||
| 630 | * @throws EE_Error |
||
| 631 | */ |
||
| 632 | public function set_visible_on($visible_on) |
||
| 636 | |||
| 637 | |||
| 638 | /** |
||
| 639 | * @param $wp_user |
||
| 640 | * @throws EE_Error |
||
| 641 | */ |
||
| 642 | public function set_wp_user($wp_user) |
||
| 646 | |||
| 647 | |||
| 648 | /** |
||
| 649 | * @param $default_registration_status |
||
| 650 | * @throws EE_Error |
||
| 651 | */ |
||
| 652 | public function set_default_registration_status($default_registration_status) |
||
| 656 | |||
| 657 | |||
| 658 | /** |
||
| 659 | * @param $donations |
||
| 660 | * @throws EE_Error |
||
| 661 | */ |
||
| 662 | public function set_donations($donations) |
||
| 666 | |||
| 667 | |||
| 668 | /** |
||
| 669 | * Adds a venue to this event |
||
| 670 | * |
||
| 671 | * @param EE_Venue /int $venue_id_or_obj |
||
| 672 | * @return EE_Base_Class|EE_Venue |
||
| 673 | * @throws EE_Error |
||
| 674 | */ |
||
| 675 | public function add_venue($venue_id_or_obj) |
||
| 679 | |||
| 680 | |||
| 681 | /** |
||
| 682 | * Removes a venue from the event |
||
| 683 | * |
||
| 684 | * @param EE_Venue /int $venue_id_or_obj |
||
| 685 | * @return EE_Base_Class|EE_Venue |
||
| 686 | * @throws EE_Error |
||
| 687 | */ |
||
| 688 | public function remove_venue($venue_id_or_obj) |
||
| 692 | |||
| 693 | |||
| 694 | /** |
||
| 695 | * Gets all the venues related ot the event. May provide additional $query_params if desired |
||
| 696 | * |
||
| 697 | * @param array $query_params like EEM_Base::get_all's $query_params |
||
| 698 | * @return EE_Base_Class[]|EE_Venue[] |
||
| 699 | * @throws EE_Error |
||
| 700 | */ |
||
| 701 | public function venues($query_params = array()) |
||
| 705 | |||
| 706 | |||
| 707 | /** |
||
| 708 | * check if event id is present and if event is published |
||
| 709 | * |
||
| 710 | * @access public |
||
| 711 | * @return boolean true yes, false no |
||
| 712 | * @throws EE_Error |
||
| 713 | */ |
||
| 714 | private function _has_ID_and_is_published() |
||
| 727 | |||
| 728 | |||
| 729 | /** |
||
| 730 | * This simply compares the internal dates with NOW and determines if the event is upcoming or not. |
||
| 731 | * |
||
| 732 | * @access public |
||
| 733 | * @return boolean true yes, false no |
||
| 734 | * @throws EE_Error |
||
| 735 | */ |
||
| 736 | View Code Duplication | public function is_upcoming() |
|
| 762 | |||
| 763 | |||
| 764 | /** |
||
| 765 | * @return bool |
||
| 766 | * @throws EE_Error |
||
| 767 | */ |
||
| 768 | View Code Duplication | public function is_active() |
|
| 794 | |||
| 795 | |||
| 796 | /** |
||
| 797 | * @return bool |
||
| 798 | * @throws EE_Error |
||
| 799 | */ |
||
| 800 | View Code Duplication | public function is_expired() |
|
| 822 | |||
| 823 | |||
| 824 | /** |
||
| 825 | * @return bool |
||
| 826 | * @throws EE_Error |
||
| 827 | */ |
||
| 828 | public function is_inactive() |
||
| 836 | |||
| 837 | |||
| 838 | /** |
||
| 839 | * calculate spaces remaining based on "saleable" tickets |
||
| 840 | * |
||
| 841 | * @param array $tickets |
||
| 842 | * @param bool $filtered |
||
| 843 | * @return int|float |
||
| 844 | * @throws EE_Error |
||
| 845 | * @throws DomainException |
||
| 846 | * @throws UnexpectedEntityException |
||
| 847 | */ |
||
| 848 | public function spaces_remaining($tickets = array(), $filtered = true) |
||
| 861 | |||
| 862 | |||
| 863 | /** |
||
| 864 | * perform_sold_out_status_check |
||
| 865 | * checks all of this events's datetime reg_limit - sold values to determine if ANY datetimes have spaces |
||
| 866 | * available... if NOT, then the event status will get toggled to 'sold_out' |
||
| 867 | * |
||
| 868 | * @return bool return the ACTUAL sold out state. |
||
| 869 | * @throws EE_Error |
||
| 870 | * @throws DomainException |
||
| 871 | * @throws UnexpectedEntityException |
||
| 872 | */ |
||
| 873 | public function perform_sold_out_status_check() |
||
| 913 | |||
| 914 | |||
| 915 | /** |
||
| 916 | * This returns the total remaining spaces for sale on this event. |
||
| 917 | * |
||
| 918 | * @uses EE_Event::total_available_spaces() |
||
| 919 | * @return float|int |
||
| 920 | * @throws EE_Error |
||
| 921 | * @throws DomainException |
||
| 922 | * @throws UnexpectedEntityException |
||
| 923 | */ |
||
| 924 | public function spaces_remaining_for_sale() |
||
| 928 | |||
| 929 | |||
| 930 | /** |
||
| 931 | * This returns the total spaces available for an event |
||
| 932 | * while considering all the qtys on the tickets and the reg limits |
||
| 933 | * on the datetimes attached to this event. |
||
| 934 | * |
||
| 935 | * @param bool $consider_sold Whether to consider any tickets that have already sold in our calculation. |
||
| 936 | * If this is false, then we return the most tickets that could ever be sold |
||
| 937 | * for this event with the datetime and tickets setup on the event under optimal |
||
| 938 | * selling conditions. Otherwise we return a live calculation of spaces available |
||
| 939 | * based on tickets sold. Depending on setup and stage of sales, this |
||
| 940 | * may appear to equal remaining tickets. However, the more tickets are |
||
| 941 | * sold out, the more accurate the "live" total is. |
||
| 942 | * @return float|int |
||
| 943 | * @throws EE_Error |
||
| 944 | * @throws DomainException |
||
| 945 | * @throws UnexpectedEntityException |
||
| 946 | */ |
||
| 947 | public function total_available_spaces($consider_sold = false) |
||
| 960 | |||
| 961 | |||
| 962 | /** |
||
| 963 | * Checks if the event is set to sold out |
||
| 964 | * |
||
| 965 | * @param bool $actual whether or not to perform calculations to not only figure the |
||
| 966 | * actual status but also to flip the status if necessary to sold |
||
| 967 | * out If false, we just check the existing status of the event |
||
| 968 | * @return boolean |
||
| 969 | * @throws EE_Error |
||
| 970 | */ |
||
| 971 | public function is_sold_out($actual = false) |
||
| 978 | |||
| 979 | |||
| 980 | /** |
||
| 981 | * Checks if the event is marked as postponed |
||
| 982 | * |
||
| 983 | * @return boolean |
||
| 984 | */ |
||
| 985 | public function is_postponed() |
||
| 989 | |||
| 990 | |||
| 991 | /** |
||
| 992 | * Checks if the event is marked as cancelled |
||
| 993 | * |
||
| 994 | * @return boolean |
||
| 995 | */ |
||
| 996 | public function is_cancelled() |
||
| 1000 | |||
| 1001 | |||
| 1002 | /** |
||
| 1003 | * Get the logical active status in a hierarchical order for all the datetimes. Note |
||
| 1004 | * Basically, we order the datetimes by EVT_start_date. Then first test on whether the event is published. If its |
||
| 1005 | * NOT published then we test for whether its expired or not. IF it IS published then we test first on whether an |
||
| 1006 | * event has any active dates. If no active dates then we check for any upcoming dates. If no upcoming dates then |
||
| 1007 | * the event is considered expired. |
||
| 1008 | * NOTE: this method does NOT calculate whether the datetimes are sold out when event is published. Sold Out is a |
||
| 1009 | * status set on the EVENT when it is not published and thus is done |
||
| 1010 | * |
||
| 1011 | * @param bool $reset |
||
| 1012 | * @return bool | string - based on EE_Datetime active constants or FALSE if error. |
||
| 1013 | * @throws EE_Error |
||
| 1014 | */ |
||
| 1015 | public function get_active_status($reset = false) |
||
| 1074 | |||
| 1075 | |||
| 1076 | /** |
||
| 1077 | * pretty_active_status |
||
| 1078 | * |
||
| 1079 | * @access public |
||
| 1080 | * @param boolean $echo whether to return (FALSE), or echo out the result (TRUE) |
||
| 1081 | * @return mixed void|string |
||
| 1082 | * @throws EE_Error |
||
| 1083 | */ |
||
| 1084 | public function pretty_active_status($echo = true) |
||
| 1098 | |||
| 1099 | |||
| 1100 | /** |
||
| 1101 | * @return bool|int |
||
| 1102 | * @throws EE_Error |
||
| 1103 | */ |
||
| 1104 | public function get_number_of_tickets_sold() |
||
| 1118 | |||
| 1119 | |||
| 1120 | /** |
||
| 1121 | * This just returns a count of all the registrations for this event |
||
| 1122 | * |
||
| 1123 | * @access public |
||
| 1124 | * @return int |
||
| 1125 | * @throws EE_Error |
||
| 1126 | */ |
||
| 1127 | public function get_count_of_all_registrations() |
||
| 1131 | |||
| 1132 | |||
| 1133 | /** |
||
| 1134 | * This returns the ticket with the earliest start time that is |
||
| 1135 | * available for this event (across all datetimes attached to the event) |
||
| 1136 | * |
||
| 1137 | * @return EE_Base_Class|EE_Ticket|null |
||
| 1138 | * @throws EE_Error |
||
| 1139 | */ |
||
| 1140 | public function get_ticket_with_earliest_start_time() |
||
| 1146 | |||
| 1147 | |||
| 1148 | /** |
||
| 1149 | * This returns the ticket with the latest end time that is available |
||
| 1150 | * for this event (across all datetimes attached to the event) |
||
| 1151 | * |
||
| 1152 | * @return EE_Base_Class|EE_Ticket|null |
||
| 1153 | * @throws EE_Error |
||
| 1154 | */ |
||
| 1155 | public function get_ticket_with_latest_end_time() |
||
| 1161 | |||
| 1162 | |||
| 1163 | /** |
||
| 1164 | * This returns the number of different ticket types currently on sale for this event. |
||
| 1165 | * |
||
| 1166 | * @return int |
||
| 1167 | * @throws EE_Error |
||
| 1168 | */ |
||
| 1169 | public function countTicketsOnSale() |
||
| 1178 | |||
| 1179 | |||
| 1180 | /** |
||
| 1181 | * This returns whether there are any tickets on sale for this event. |
||
| 1182 | * |
||
| 1183 | * @return bool true = YES tickets on sale. |
||
| 1184 | * @throws EE_Error |
||
| 1185 | */ |
||
| 1186 | public function tickets_on_sale() |
||
| 1190 | |||
| 1191 | |||
| 1192 | /** |
||
| 1193 | * Gets the URL for viewing this event on the front-end. Overrides parent |
||
| 1194 | * to check for an external URL first |
||
| 1195 | * |
||
| 1196 | * @return string |
||
| 1197 | * @throws EE_Error |
||
| 1198 | */ |
||
| 1199 | public function get_permalink() |
||
| 1206 | |||
| 1207 | |||
| 1208 | /** |
||
| 1209 | * Gets the first term for 'espresso_event_categories' we can find |
||
| 1210 | * |
||
| 1211 | * @param array $query_params like EEM_Base::get_all |
||
| 1212 | * @return EE_Base_Class|EE_Term|null |
||
| 1213 | * @throws EE_Error |
||
| 1214 | */ |
||
| 1215 | public function first_event_category($query_params = array()) |
||
| 1221 | |||
| 1222 | |||
| 1223 | /** |
||
| 1224 | * Gets all terms for 'espresso_event_categories' we can find |
||
| 1225 | * |
||
| 1226 | * @param array $query_params |
||
| 1227 | * @return EE_Base_Class[]|EE_Term[] |
||
| 1228 | * @throws EE_Error |
||
| 1229 | */ |
||
| 1230 | public function get_all_event_categories($query_params = array()) |
||
| 1236 | |||
| 1237 | |||
| 1238 | /** |
||
| 1239 | * Adds a question group to this event |
||
| 1240 | * |
||
| 1241 | * @param EE_Question_Group|int $question_group_id_or_obj |
||
| 1242 | * @param bool $for_primary if true, the question group will be added for the primary |
||
| 1243 | * registrant, if false will be added for others. default: false |
||
| 1244 | * @return EE_Base_Class|EE_Question_Group |
||
| 1245 | * @throws EE_Error |
||
| 1246 | */ |
||
| 1247 | public function add_question_group($question_group_id_or_obj, $for_primary = false) |
||
| 1254 | |||
| 1255 | |||
| 1256 | /** |
||
| 1257 | * Removes a question group from the event |
||
| 1258 | * |
||
| 1259 | * @param EE_Question_Group|int $question_group_id_or_obj |
||
| 1260 | * @param bool $for_primary if true, the question group will be removed from the primary |
||
| 1261 | * registrant, if false will be removed from others. default: false |
||
| 1262 | * @return EE_Base_Class|EE_Question_Group |
||
| 1263 | * @throws EE_Error |
||
| 1264 | */ |
||
| 1265 | public function remove_question_group($question_group_id_or_obj, $for_primary = false) |
||
| 1272 | |||
| 1273 | |||
| 1274 | /** |
||
| 1275 | * Gets all the question groups, ordering them by QSG_order ascending |
||
| 1276 | * |
||
| 1277 | * @param array $query_params @see EEM_Base::get_all |
||
| 1278 | * @return EE_Base_Class[]|EE_Question_Group[] |
||
| 1279 | * @throws EE_Error |
||
| 1280 | */ |
||
| 1281 | public function question_groups($query_params = array()) |
||
| 1286 | |||
| 1287 | |||
| 1288 | /** |
||
| 1289 | * Implementation for EEI_Has_Icon interface method. |
||
| 1290 | * |
||
| 1291 | * @see EEI_Visual_Representation for comments |
||
| 1292 | * @return string |
||
| 1293 | */ |
||
| 1294 | public function get_icon() |
||
| 1298 | |||
| 1299 | |||
| 1300 | /** |
||
| 1301 | * Implementation for EEI_Admin_Links interface method. |
||
| 1302 | * |
||
| 1303 | * @see EEI_Admin_Links for comments |
||
| 1304 | * @return string |
||
| 1305 | * @throws EE_Error |
||
| 1306 | */ |
||
| 1307 | public function get_admin_details_link() |
||
| 1311 | |||
| 1312 | |||
| 1313 | /** |
||
| 1314 | * Implementation for EEI_Admin_Links interface method. |
||
| 1315 | * |
||
| 1316 | * @see EEI_Admin_Links for comments |
||
| 1317 | * @return string |
||
| 1318 | * @throws EE_Error |
||
| 1319 | */ |
||
| 1320 | public function get_admin_edit_link() |
||
| 1331 | |||
| 1332 | |||
| 1333 | /** |
||
| 1334 | * Implementation for EEI_Admin_Links interface method. |
||
| 1335 | * |
||
| 1336 | * @see EEI_Admin_Links for comments |
||
| 1337 | * @return string |
||
| 1338 | */ |
||
| 1339 | public function get_admin_settings_link() |
||
| 1349 | |||
| 1350 | |||
| 1351 | /** |
||
| 1352 | * Implementation for EEI_Admin_Links interface method. |
||
| 1353 | * |
||
| 1354 | * @see EEI_Admin_Links for comments |
||
| 1355 | * @return string |
||
| 1356 | */ |
||
| 1357 | public function get_admin_overview_link() |
||
| 1367 | } |
||
| 1368 |
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.