[REF] Change function signature to support moving this off the form layer
authoreileen <emcnaughton@wikimedia.org>
Tue, 3 Mar 2020 19:54:04 +0000 (08:54 +1300)
committereileen <emcnaughton@wikimedia.org>
Thu, 5 Mar 2020 00:01:09 +0000 (13:01 +1300)
This is really a business logic function & belongs on the BAO. This change simply removes the
access to  such that it can be moved by making it an input parameter.

Next step would be o make it static & move  it to CRM_Member_BAO_Membership

Evenually this should not be called by the form as the CRM_Member_BAO_Membership
::create function will call it

CRM/Contact/Form/Contact.php

index fff49c33765eb0aaf811d4216b1e0206dba88ca1..df3a342e4a5473a3224739976855f12dd2e04c29 100644 (file)
@@ -914,7 +914,7 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form {
         'is_deceased' => CRM_Utils_Array::value('is_deceased', $params, FALSE),
         'deceased_date' => CRM_Utils_Array::value('deceased_date', $params, NULL),
       ];
-      $updateMembershipMsg = $this->updateMembershipStatus($deceasedParams);
+      $updateMembershipMsg = $this->updateMembershipStatus($deceasedParams, $this->_contactType);
     }
 
     // action is taken depending upon the mode
@@ -1399,19 +1399,23 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form {
    * function return the status message for updated membership.
    *
    * @param array $deceasedParams
-   *   having contact id and deceased value.
+   *  - contact id
+   *  - is_deceased
+   *  - deceased_date
+   *
+   * @param string $contactType
    *
    * @return null|string
    *   $updateMembershipMsg string  status message for updated membership.
    */
-  public function updateMembershipStatus($deceasedParams) {
+  public function updateMembershipStatus($deceasedParams, $contactType) {
     $updateMembershipMsg = NULL;
     $contactId = CRM_Utils_Array::value('contact_id', $deceasedParams);
     $deceasedDate = CRM_Utils_Array::value('deceased_date', $deceasedParams);
 
     // process to set membership status to deceased for both active/inactive membership
     if ($contactId &&
-      $this->_contactType == 'Individual' && !empty($deceasedParams['is_deceased'])
+      $contactType === 'Individual' && !empty($deceasedParams['is_deceased'])
     ) {
 
       $session = CRM_Core_Session::singleton();