Complex classes like OrderStep 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 OrderStep, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 12 | class OrderStep extends DataObject implements EditableEcommerceObject |
||
|
|
|||
| 13 | { |
||
| 14 | |||
| 15 | /** |
||
| 16 | * standard SS variable. |
||
| 17 | * |
||
| 18 | * @return array |
||
| 19 | */ |
||
| 20 | private static $db = array( |
||
| 21 | 'Name' => 'Varchar(50)', |
||
| 22 | 'Code' => 'Varchar(50)', |
||
| 23 | 'Description' => 'Text', |
||
| 24 | 'EmailSubject' => 'Varchar(200)', |
||
| 25 | 'CustomerMessage' => 'HTMLText', |
||
| 26 | //customer privileges |
||
| 27 | 'CustomerCanEdit' => 'Boolean', |
||
| 28 | 'CustomerCanCancel' => 'Boolean', |
||
| 29 | 'CustomerCanPay' => 'Boolean', |
||
| 30 | //What to show the customer... |
||
| 31 | 'ShowAsUncompletedOrder' => 'Boolean', |
||
| 32 | 'ShowAsInProcessOrder' => 'Boolean', |
||
| 33 | 'ShowAsCompletedOrder' => 'Boolean', |
||
| 34 | 'HideStepFromCustomer' => 'Boolean', |
||
| 35 | //sorting index |
||
| 36 | 'Sort' => 'Int', |
||
| 37 | 'DeferTimeInSeconds' => 'Int', |
||
| 38 | 'DeferFromSubmitTime' => 'Boolean' |
||
| 39 | ); |
||
| 40 | |||
| 41 | |||
| 42 | |||
| 43 | /** |
||
| 44 | * standard SS variable. |
||
| 45 | * |
||
| 46 | * @return array |
||
| 47 | */ |
||
| 48 | private static $indexes = array( |
||
| 49 | 'Code' => true, |
||
| 50 | 'Sort' => true, |
||
| 51 | ); |
||
| 52 | |||
| 53 | /** |
||
| 54 | * standard SS variable. |
||
| 55 | * |
||
| 56 | * @return array |
||
| 57 | */ |
||
| 58 | private static $has_many = array( |
||
| 59 | 'Orders' => 'Order', |
||
| 60 | 'OrderEmailRecords' => 'OrderEmailRecord', |
||
| 61 | ); |
||
| 62 | |||
| 63 | /** |
||
| 64 | * standard SS variable. |
||
| 65 | * |
||
| 66 | * @return array |
||
| 67 | */ |
||
| 68 | private static $field_labels = array( |
||
| 69 | 'Sort' => 'Sorting Index', |
||
| 70 | 'CustomerCanEdit' => 'Customer can edit order', |
||
| 71 | 'CustomerCanPay' => 'Customer can pay order', |
||
| 72 | 'CustomerCanCancel' => 'Customer can cancel order', |
||
| 73 | ); |
||
| 74 | |||
| 75 | /** |
||
| 76 | * standard SS variable. |
||
| 77 | * |
||
| 78 | * @return array |
||
| 79 | */ |
||
| 80 | private static $summary_fields = array( |
||
| 81 | 'NameAndDescription' => 'Step', |
||
| 82 | 'ShowAsSummary' => 'Phase', |
||
| 83 | ); |
||
| 84 | |||
| 85 | /** |
||
| 86 | * standard SS variable. |
||
| 87 | * |
||
| 88 | * @return array |
||
| 89 | */ |
||
| 90 | private static $casting = array( |
||
| 91 | 'Title' => 'Varchar', |
||
| 92 | 'CustomerCanEditNice' => 'Varchar', |
||
| 93 | 'CustomerCanPayNice' => 'Varchar', |
||
| 94 | 'CustomerCanCancelNice' => 'Varchar', |
||
| 95 | 'ShowAsUncompletedOrderNice' => 'Varchar', |
||
| 96 | 'ShowAsInProcessOrderNice' => 'Varchar', |
||
| 97 | 'ShowAsCompletedOrderNice' => 'Varchar', |
||
| 98 | 'HideStepFromCustomerNice' => 'Varchar', |
||
| 99 | 'HasCustomerMessageNice' => 'Varchar', |
||
| 100 | 'ShowAsSummary' => 'HTMLText', |
||
| 101 | 'NameAndDescription' => 'HTMLText' |
||
| 102 | ); |
||
| 103 | |||
| 104 | /** |
||
| 105 | * standard SS variable. |
||
| 106 | * |
||
| 107 | * @return array |
||
| 108 | */ |
||
| 109 | private static $searchable_fields = array( |
||
| 110 | 'Name' => array( |
||
| 111 | 'title' => 'Name', |
||
| 112 | 'filter' => 'PartialMatchFilter', |
||
| 113 | ), |
||
| 114 | 'Code' => array( |
||
| 115 | 'title' => 'Code', |
||
| 116 | 'filter' => 'PartialMatchFilter', |
||
| 117 | ), |
||
| 118 | ); |
||
| 119 | |||
| 120 | |||
| 121 | /** |
||
| 122 | * casted variable. |
||
| 123 | * |
||
| 124 | * @return string |
||
| 125 | */ |
||
| 126 | public function Title() |
||
| 134 | |||
| 135 | /** |
||
| 136 | * casted variable. |
||
| 137 | * |
||
| 138 | * @return string |
||
| 139 | */ |
||
| 140 | public function CustomerCanEditNice() |
||
| 152 | |||
| 153 | /** |
||
| 154 | * casted variable. |
||
| 155 | * |
||
| 156 | * @return string |
||
| 157 | */ |
||
| 158 | public function CustomerCanPayNice() |
||
| 170 | |||
| 171 | /** |
||
| 172 | * casted variable. |
||
| 173 | * |
||
| 174 | * @return string |
||
| 175 | */ |
||
| 176 | public function CustomerCanCancelNice() |
||
| 188 | |||
| 189 | public function ShowAsUncompletedOrderNice() |
||
| 201 | |||
| 202 | /** |
||
| 203 | * casted variable. |
||
| 204 | * |
||
| 205 | * @return string |
||
| 206 | */ |
||
| 207 | public function ShowAsInProcessOrderNice() |
||
| 219 | |||
| 220 | /** |
||
| 221 | * casted variable. |
||
| 222 | * |
||
| 223 | * @return string |
||
| 224 | */ |
||
| 225 | public function ShowAsCompletedOrderNice() |
||
| 237 | |||
| 238 | /** |
||
| 239 | * do not show in steps at all. |
||
| 240 | * @return boolean |
||
| 241 | */ |
||
| 242 | public function HideFromEveryone() |
||
| 246 | |||
| 247 | /** |
||
| 248 | * casted variable. |
||
| 249 | * |
||
| 250 | * @return string |
||
| 251 | */ |
||
| 252 | public function HideStepFromCustomerNice() |
||
| 256 | |||
| 257 | public function getHideStepFromCustomerNice() |
||
| 265 | |||
| 266 | /** |
||
| 267 | * standard SS variable. |
||
| 268 | * |
||
| 269 | * @return string |
||
| 270 | */ |
||
| 271 | private static $singular_name = 'Order Step'; |
||
| 272 | public function i18n_singular_name() |
||
| 276 | |||
| 277 | /** |
||
| 278 | * standard SS variable. |
||
| 279 | * |
||
| 280 | * @return string |
||
| 281 | */ |
||
| 282 | private static $plural_name = 'Order Steps'; |
||
| 283 | public function i18n_plural_name() |
||
| 287 | |||
| 288 | /** |
||
| 289 | * Standard SS variable. |
||
| 290 | * |
||
| 291 | * @var string |
||
| 292 | */ |
||
| 293 | private static $description = 'A step that any order goes through.'; |
||
| 294 | |||
| 295 | /** |
||
| 296 | * SUPER IMPORTANT TO KEEP ORDER! |
||
| 297 | * standard SS variable. |
||
| 298 | * |
||
| 299 | * @return string |
||
| 300 | */ |
||
| 301 | private static $default_sort = '"Sort" ASC'; |
||
| 302 | |||
| 303 | /** |
||
| 304 | * returns all the order steps |
||
| 305 | * that the admin should / can edit.... |
||
| 306 | * |
||
| 307 | * @return DataList |
||
| 308 | */ |
||
| 309 | public static function admin_manageable_steps() |
||
| 314 | |||
| 315 | /** |
||
| 316 | * return StatusIDs (orderstep IDs) from orders that are bad.... |
||
| 317 | * (basically StatusID values that do not exist) |
||
| 318 | * |
||
| 319 | * @return array |
||
| 320 | */ |
||
| 321 | public static function bad_order_step_ids() |
||
| 333 | |||
| 334 | /** |
||
| 335 | * turns code into ID. |
||
| 336 | * |
||
| 337 | * @param string $code |
||
| 338 | * @param int |
||
| 339 | */ |
||
| 340 | public static function get_status_id_from_code($code) |
||
| 351 | |||
| 352 | /** |
||
| 353 | *@return array |
||
| 354 | **/ |
||
| 355 | public static function get_codes_for_order_steps_to_include() |
||
| 368 | |||
| 369 | /** |
||
| 370 | * returns a list of ordersteps that have not been created yet. |
||
| 371 | * |
||
| 372 | * @return array |
||
| 373 | **/ |
||
| 374 | public static function get_not_created_codes_for_order_steps_to_include() |
||
| 388 | |||
| 389 | /** |
||
| 390 | *@return string |
||
| 391 | **/ |
||
| 392 | public function getMyCode() |
||
| 401 | |||
| 402 | /** |
||
| 403 | * IMPORTANT:: MUST HAVE Code must be defined!!! |
||
| 404 | * standard SS variable. |
||
| 405 | * |
||
| 406 | * @return array |
||
| 407 | */ |
||
| 408 | private static $defaults = array( |
||
| 409 | 'CustomerCanEdit' => 0, |
||
| 410 | 'CustomerCanCancel' => 0, |
||
| 411 | 'CustomerCanPay' => 1, |
||
| 412 | 'ShowAsUncompletedOrder' => 0, |
||
| 413 | 'ShowAsInProcessOrder' => 0, |
||
| 414 | 'ShowAsCompletedOrder' => 0, |
||
| 415 | 'Code' => 'ORDERSTEP', |
||
| 416 | ); |
||
| 417 | |||
| 418 | /** |
||
| 419 | * standard SS method. |
||
| 420 | */ |
||
| 421 | public function populateDefaults() |
||
| 426 | |||
| 427 | /** |
||
| 428 | *@return FieldList |
||
| 429 | **/ |
||
| 430 | public function getCMSFields() |
||
| 513 | |||
| 514 | /** |
||
| 515 | * link to edit the record. |
||
| 516 | * |
||
| 517 | * @param string | Null $action - e.g. edit |
||
| 518 | * |
||
| 519 | * @return string |
||
| 520 | */ |
||
| 521 | public function CMSEditLink($action = null) |
||
| 529 | |||
| 530 | /** |
||
| 531 | * tells the order to display itself with an alternative display page. |
||
| 532 | * in that way, orders can be displayed differently for certain steps |
||
| 533 | * for example, in a print step, the order can be displayed in a |
||
| 534 | * PRINT ONLY format. |
||
| 535 | * |
||
| 536 | * When the method return null, the order is displayed using the standard display page |
||
| 537 | * |
||
| 538 | * @see Order::DisplayPage |
||
| 539 | * |
||
| 540 | * @return null|object (Page) |
||
| 541 | **/ |
||
| 542 | public function AlternativeDisplayPage() |
||
| 546 | |||
| 547 | /** |
||
| 548 | * Allows the opportunity for the Order Step to add any fields to Order::getCMSFields |
||
| 549 | * Usually this is added before ActionNextStepManually. |
||
| 550 | * |
||
| 551 | * @param FieldList $fields |
||
| 552 | * @param Order $order |
||
| 553 | * |
||
| 554 | * @return FieldList |
||
| 555 | **/ |
||
| 556 | public function addOrderStepFields(FieldList $fields, Order $order) |
||
| 560 | |||
| 561 | /** |
||
| 562 | *@return ValidationResult |
||
| 563 | **/ |
||
| 564 | public function validate() |
||
| 582 | |||
| 583 | /************************************************** |
||
| 584 | * moving between statusses... |
||
| 585 | **************************************************/ |
||
| 586 | /** |
||
| 587 | *initStep: |
||
| 588 | * makes sure the step is ready to run.... (e.g. check if the order is ready to be emailed as receipt). |
||
| 589 | * should be able to run this function many times to check if the step is ready. |
||
| 590 | * |
||
| 591 | * @see Order::doNextStatus |
||
| 592 | * |
||
| 593 | * @param Order object |
||
| 594 | * |
||
| 595 | * @return bool - true if the current step is ready to be run... |
||
| 596 | **/ |
||
| 597 | public function initStep(Order $order) |
||
| 603 | |||
| 604 | /** |
||
| 605 | *doStep: |
||
| 606 | * should only be able to run this function once |
||
| 607 | * (init stops you from running it twice - in theory....) |
||
| 608 | * runs the actual step. |
||
| 609 | * |
||
| 610 | * @see Order::doNextStatus |
||
| 611 | * |
||
| 612 | * @param Order object |
||
| 613 | * |
||
| 614 | * @return bool - true if run correctly. |
||
| 615 | **/ |
||
| 616 | public function doStep(Order $order) |
||
| 622 | |||
| 623 | /** |
||
| 624 | * nextStep: |
||
| 625 | * returns the next step (after it checks if everything is in place for the next step to run...). |
||
| 626 | * |
||
| 627 | * @see Order::doNextStatus |
||
| 628 | * |
||
| 629 | * @param Order $order |
||
| 630 | * |
||
| 631 | * @return OrderStep | Null (next step OrderStep object) |
||
| 632 | **/ |
||
| 633 | public function nextStep(Order $order) |
||
| 644 | |||
| 645 | /************************************************** |
||
| 646 | * Boolean checks |
||
| 647 | **************************************************/ |
||
| 648 | |||
| 649 | /** |
||
| 650 | * Checks if a step has passed (been completed) in comparison to the current step. |
||
| 651 | * |
||
| 652 | * @param string $code: the name of the step to check |
||
| 653 | * @param bool $orIsEqualTo if set to true, this method will return TRUE if the step being checked is the current one |
||
| 654 | * |
||
| 655 | * @return bool |
||
| 656 | **/ |
||
| 657 | public function hasPassed($code, $orIsEqualTo = false) |
||
| 675 | |||
| 676 | /** |
||
| 677 | * @param string $code |
||
| 678 | * |
||
| 679 | * @return bool |
||
| 680 | **/ |
||
| 681 | public function hasPassedOrIsEqualTo($code) |
||
| 685 | |||
| 686 | /** |
||
| 687 | * @param string $code |
||
| 688 | * |
||
| 689 | * @return bool |
||
| 690 | **/ |
||
| 691 | public function hasNotPassed($code) |
||
| 695 | |||
| 696 | /** |
||
| 697 | * Opposite of hasPassed. |
||
| 698 | * |
||
| 699 | * @param string $code |
||
| 700 | * |
||
| 701 | * @return bool |
||
| 702 | **/ |
||
| 703 | public function isBefore($code) |
||
| 707 | |||
| 708 | /** |
||
| 709 | *@return bool |
||
| 710 | **/ |
||
| 711 | protected function isDefaultStatusOption() |
||
| 715 | |||
| 716 | /************************************************** |
||
| 717 | |||
| 718 | **************************************************/ |
||
| 719 | |||
| 720 | /** |
||
| 721 | * @var string |
||
| 722 | */ |
||
| 723 | protected $emailClassName = ''; |
||
| 724 | |||
| 725 | /** |
||
| 726 | * returns the email class used for emailing the |
||
| 727 | * customer during a specific step (IF ANY!). |
||
| 728 | * |
||
| 729 | * @return string |
||
| 730 | */ |
||
| 731 | public function getEmailClassName() |
||
| 735 | |||
| 736 | /** |
||
| 737 | * return true if done already or mailed successfully now. |
||
| 738 | * |
||
| 739 | * @param order $order |
||
| 740 | * @param string $subject |
||
| 741 | * @param string $message |
||
| 742 | * @param bool $resend |
||
| 743 | * @param bool | string $adminOnlyOrToEmail you can set to false = send to customer, true: send to admin, or email = send to email |
||
| 744 | * @param string $emailClassName |
||
| 745 | * |
||
| 746 | * @return boolean; |
||
| 747 | */ |
||
| 748 | protected function sendEmailForStep( |
||
| 794 | |||
| 795 | /** |
||
| 796 | * sets the email class used for emailing the |
||
| 797 | * customer during a specific step (IF ANY!). |
||
| 798 | * |
||
| 799 | * @param string |
||
| 800 | */ |
||
| 801 | public function setEmailClassName($s) |
||
| 805 | |||
| 806 | /** |
||
| 807 | * returns a link that can be used to test |
||
| 808 | * the email being sent during this step |
||
| 809 | * this method returns NULL if no email |
||
| 810 | * is being sent OR if there is no suitable Order |
||
| 811 | * to test with... |
||
| 812 | * |
||
| 813 | * @return string |
||
| 814 | */ |
||
| 815 | protected function testEmailLink() |
||
| 829 | |||
| 830 | /** |
||
| 831 | * Has an email been sent to the customer for this |
||
| 832 | * order step. |
||
| 833 | *"-10 days". |
||
| 834 | * |
||
| 835 | * @param Order $order |
||
| 836 | * @param bool $checkDateOfOrder |
||
| 837 | * |
||
| 838 | * @return bool |
||
| 839 | **/ |
||
| 840 | public function hasBeenSent(Order $order, $checkDateOfOrder = true) |
||
| 864 | |||
| 865 | /** |
||
| 866 | * For some ordersteps this returns true... |
||
| 867 | * |
||
| 868 | * @return bool |
||
| 869 | **/ |
||
| 870 | protected function hasCustomerMessage() |
||
| 874 | |||
| 875 | /** |
||
| 876 | * can this order step be delayed? |
||
| 877 | * @return bool |
||
| 878 | **/ |
||
| 879 | protected function canBeDefered() |
||
| 880 | { |
||
| 881 | return $this->hasCustomerMessage(); |
||
| 882 | } |
||
| 883 | |||
| 884 | /** |
||
| 885 | * Formatted answer for "hasCustomerMessage". |
||
| 886 | * |
||
| 887 | * @return string |
||
| 888 | */ |
||
| 889 | public function HasCustomerMessageNice() |
||
| 890 | { |
||
| 891 | return $this->getHasCustomerMessageNice(); |
||
| 892 | } |
||
| 893 | public function getHasCustomerMessageNice() |
||
| 894 | { |
||
| 895 | return $this->hasCustomerMessage() ? _t('OrderStep.YES', 'Yes') : _t('OrderStep.NO', 'No'); |
||
| 896 | } |
||
| 897 | |||
| 898 | /** |
||
| 899 | * Formatted answer for "hasCustomerMessage". |
||
| 900 | * |
||
| 901 | * @return string |
||
| 902 | */ |
||
| 903 | public function ShowAsSummary() |
||
| 904 | { |
||
| 905 | return $this->getShowAsSummary(); |
||
| 906 | } |
||
| 907 | |||
| 908 | /** |
||
| 909 | * |
||
| 910 | * |
||
| 911 | * @return string |
||
| 912 | */ |
||
| 913 | public function getShowAsSummary() |
||
| 914 | { |
||
| 915 | $v = '<strong>'; |
||
| 916 | if ($this->ShowAsUncompletedOrder) { |
||
| 917 | $v .= _t('OrderStep.UNCOMPLETED', 'Uncompleted'); |
||
| 918 | } elseif ($this->ShowAsInProcessOrder) { |
||
| 919 | $v .= _t('OrderStep.INPROCESS', 'In process'); |
||
| 920 | } elseif ($this->ShowAsCompletedOrder) { |
||
| 921 | $v .= _t('OrderStep.COMPLETED', 'Completed'); |
||
| 922 | } |
||
| 923 | $v .= '</strong>'; |
||
| 924 | $canArray = array(); |
||
| 925 | if ($this->CustomerCanEdit) { |
||
| 926 | $canArray[] = _t('OrderStep.EDITABLE', 'edit'); |
||
| 927 | } |
||
| 928 | if ($this->CustomerCanPay) { |
||
| 929 | $canArray[] = _t('OrderStep.PAY', 'pay'); |
||
| 930 | } |
||
| 931 | if ($this->CustomerCanCancel) { |
||
| 932 | $canArray[] = _t('OrderStep.CANCEL', 'cancel'); |
||
| 933 | } |
||
| 934 | if (count($canArray)) { |
||
| 935 | $v .= '<br />'._t('OrderStep.CUSTOMER_CAN', 'Customer Can').': '.implode(', ', $canArray).''; |
||
| 936 | } |
||
| 937 | if ($this->hasCustomerMessage()) { |
||
| 938 | $v .= '<br />'._t('OrderStep.CUSTOMER_MESSAGES', 'Includes message to customer'); |
||
| 939 | } |
||
| 940 | if ($this->DeferTimeInSeconds) { |
||
| 941 | $v .= '<br />'.$this->humanReadeableDeferTimeInSeconds(); |
||
| 942 | } |
||
| 943 | |||
| 944 | return DBField::create_field('HTMLText', $v); |
||
| 945 | } |
||
| 946 | |||
| 947 | /** |
||
| 948 | * @return string |
||
| 949 | */ |
||
| 950 | protected function humanReadeableDeferTimeInSeconds() |
||
| 951 | { |
||
| 952 | if ($this->canBeDefered()) { |
||
| 953 | $field = DBField::create_field('SS_DateTime', strtotime('+ '.$this->DeferTimeInSeconds.' seconds')); |
||
| 954 | $descr0 = _t('OrderStep.THE', 'The').' '.'<span style="color: #338DC1">'.$this->getTitle().'</span>'; |
||
| 955 | $descr1 = _t('OrderStep.DELAY_VALUE', 'Order Step, for any order, will run'); |
||
| 956 | $descr2 = $field->ago(); |
||
| 957 | $descr3 = $this->DeferFromSubmitTime ? |
||
| 958 | _t('OrderStep.FROM_ORDER_SUBMIT_TIME', 'from the order being submitted') : |
||
| 959 | _t('OrderStep.FROM_START_OF_ORDSTEP', 'from the order arriving on this step'); |
||
| 960 | return $descr0. ' ' . $descr1.' <span style="color: #338DC1">'.$descr2.'</span> '.$descr3.'.'; |
||
| 961 | } |
||
| 962 | // $dtF = new \DateTime('@0'); |
||
| 963 | // $dtT = new \DateTime("@".$this->DeferTimeInSeconds); |
||
| 964 | // |
||
| 965 | // return $dtF->diff($dtT)->format('%a days, %h hours, %i minutes and %s seconds'); |
||
| 966 | } |
||
| 967 | |||
| 968 | /** |
||
| 969 | * Formatted answer for "hasCustomerMessage". |
||
| 970 | * |
||
| 971 | * @return string |
||
| 972 | */ |
||
| 973 | public function NameAndDescription() |
||
| 974 | { |
||
| 975 | return $this->getNameAndDescription(); |
||
| 976 | } |
||
| 977 | |||
| 978 | public function getNameAndDescription() |
||
| 979 | { |
||
| 980 | $v = '<strong>'.$this->Name.'</strong><br /><em>'.$this->Description.'</em>'; |
||
| 981 | |||
| 982 | return DBField::create_field('HTMLText', $v); |
||
| 983 | } |
||
| 984 | |||
| 985 | /** |
||
| 986 | * This allows you to set the time to something other than the standard DeferTimeInSeconds |
||
| 987 | * value based on the order provided. |
||
| 988 | * |
||
| 989 | * @param Order |
||
| 990 | * |
||
| 991 | * @return int |
||
| 992 | */ |
||
| 993 | public function CalculatedDeferedTimeInSeconds($order) |
||
| 994 | { |
||
| 995 | return $this->DeferTimeInSeconds; |
||
| 996 | } |
||
| 997 | |||
| 998 | /** |
||
| 999 | * can this order step be delayed? |
||
| 1000 | * @return bool |
||
| 1001 | **/ |
||
| 1002 | protected function canBeDefered() |
||
| 1006 | |||
| 1007 | |||
| 1008 | /************************************************** |
||
| 1009 | * Order Status Logs |
||
| 1010 | **************************************************/ |
||
| 1011 | |||
| 1012 | /** |
||
| 1013 | * The OrderStatusLog that is relevant to the particular step. |
||
| 1014 | * |
||
| 1015 | * @var string |
||
| 1016 | */ |
||
| 1017 | protected $relevantLogEntryClassName = ''; |
||
| 1018 | |||
| 1019 | /** |
||
| 1020 | * @return string |
||
| 1021 | */ |
||
| 1022 | public function getRelevantLogEntryClassName() |
||
| 1026 | |||
| 1027 | /** |
||
| 1028 | * @param string |
||
| 1029 | */ |
||
| 1030 | public function setRelevantLogEntryClassName($s) |
||
| 1034 | |||
| 1035 | /** |
||
| 1036 | * returns the OrderStatusLog that is relevant to this step. |
||
| 1037 | * |
||
| 1038 | * @param Order $order |
||
| 1039 | * |
||
| 1040 | * @return OrderStatusLog | null |
||
| 1041 | */ |
||
| 1042 | public function RelevantLogEntry(Order $order) |
||
| 1048 | |||
| 1049 | /** |
||
| 1050 | * returns the OrderStatusLogs that are relevant to this step. |
||
| 1051 | * |
||
| 1052 | * @param Order $order |
||
| 1053 | * |
||
| 1054 | * @return DataObjectSet | null |
||
| 1055 | */ |
||
| 1056 | public function RelevantLogEntries(Order $order) |
||
| 1062 | |||
| 1063 | /************************************************** |
||
| 1064 | * Silverstripe Standard Data Object Methods |
||
| 1065 | **************************************************/ |
||
| 1066 | |||
| 1067 | /** |
||
| 1068 | * Standard SS method |
||
| 1069 | * These are only created programmatically. |
||
| 1070 | * |
||
| 1071 | * @param Member $member |
||
| 1072 | * |
||
| 1073 | * @return bool |
||
| 1074 | */ |
||
| 1075 | public function canCreate($member = null) |
||
| 1079 | |||
| 1080 | /** |
||
| 1081 | * Standard SS method. |
||
| 1082 | * |
||
| 1083 | * @param Member $member |
||
| 1084 | * |
||
| 1085 | * @return bool |
||
| 1086 | */ |
||
| 1087 | public function canView($member = null) |
||
| 1102 | |||
| 1103 | /** |
||
| 1104 | * the default for this is TRUE, but for completed order steps |
||
| 1105 | * |
||
| 1106 | * we do not allow this. |
||
| 1107 | * |
||
| 1108 | * @param Order $order |
||
| 1109 | * @param Member $member optional |
||
| 1110 | * @return bool |
||
| 1111 | */ |
||
| 1112 | public function canOverrideCanViewForOrder($order, $member = null) |
||
| 1121 | |||
| 1122 | /** |
||
| 1123 | * standard SS method. |
||
| 1124 | * |
||
| 1125 | * @param Member | NULL |
||
| 1126 | * |
||
| 1127 | * @return bool |
||
| 1128 | */ |
||
| 1129 | public function canEdit($member = null) |
||
| 1144 | |||
| 1145 | /** |
||
| 1146 | * Standard SS method. |
||
| 1147 | * |
||
| 1148 | * @param Member $member |
||
| 1149 | * |
||
| 1150 | * @return bool |
||
| 1151 | */ |
||
| 1152 | public function canDelete($member = null) |
||
| 1182 | |||
| 1183 | /** |
||
| 1184 | * standard SS method. |
||
| 1185 | */ |
||
| 1186 | public function onBeforeWrite() |
||
| 1215 | |||
| 1216 | /** |
||
| 1217 | * move linked orders to the next status |
||
| 1218 | * standard SS method. |
||
| 1219 | */ |
||
| 1220 | public function onBeforeDelete() |
||
| 1241 | |||
| 1242 | /** |
||
| 1243 | * standard SS method. |
||
| 1244 | */ |
||
| 1245 | public function onAfterDelete() |
||
| 1250 | |||
| 1251 | protected function NextOrderStep() |
||
| 1257 | |||
| 1258 | protected function PreviousOrderStep() |
||
| 1264 | |||
| 1265 | /** |
||
| 1266 | * standard SS method |
||
| 1267 | * USED TO BE: Unpaid,Query,Paid,Processing,Sent,Complete,AdminCancelled,MemberCancelled,Cart. |
||
| 1268 | */ |
||
| 1269 | public function requireDefaultRecords() |
||
| 1322 | |||
| 1323 | /** |
||
| 1324 | * returns the standard EcommerceDBConfig for use within OrderSteps. |
||
| 1325 | * |
||
| 1326 | * @return EcommerceDBConfig |
||
| 1327 | */ |
||
| 1328 | protected function EcomConfig() |
||
| 1332 | |||
| 1333 | /** |
||
| 1334 | * Explains the current order step. |
||
| 1335 | * |
||
| 1336 | * @return string |
||
| 1337 | */ |
||
| 1338 | protected function myDescription() |
||
| 1342 | } |
||
| 1343 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.