From e346b6bc796d87045b82c0617638bd984953c47b Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 28 Feb 2023 12:23:23 +1300 Subject: [PATCH] Also remove CRM_Utils_Array call --- CRM/Member/BAO/MembershipType.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/CRM/Member/BAO/MembershipType.php b/CRM/Member/BAO/MembershipType.php index 4e10b491d5..59e52c960b 100644 --- a/CRM/Member/BAO/MembershipType.php +++ b/CRM/Member/BAO/MembershipType.php @@ -67,34 +67,32 @@ class CRM_Member_BAO_MembershipType extends CRM_Member_DAO_MembershipType implem */ public static function add(&$params) { $hook = empty($params['id']) ? 'create' : 'edit'; - CRM_Utils_Hook::pre($hook, 'MembershipType', CRM_Utils_Array::value('id', $params), $params); + $membershipTypeID = $params['id'] ?? NULL; + CRM_Utils_Hook::pre($hook, 'MembershipType', $membershipTypeID, $params); - $membershipTypeId = $params['id'] ?? NULL; - - if (!$membershipTypeId && !isset($params['domain_id'])) { + if (!$membershipTypeID && !isset($params['domain_id'])) { $params['domain_id'] = CRM_Core_Config::domainID(); } // $previousID is the old organization id for membership type i.e 'member_of_contact_id'. This is used when an organization is changed. $previousID = NULL; - if ($membershipTypeId) { - $previousID = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $membershipTypeId, 'member_of_contact_id'); + if ($membershipTypeID) { + $previousID = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $membershipTypeID, 'member_of_contact_id'); } - // action is taken depending upon the mode $membershipType = new CRM_Member_DAO_MembershipType(); $membershipType->copyValues($params); $membershipType->save(); - if ($membershipTypeId) { + if ($membershipTypeID) { // on update we may need to retrieve some details for the price field function - otherwise we get e-notices on attempts to retrieve // name etc - the presence of previous id tells us this is an update $params = array_merge(civicrm_api3('membership_type', 'getsingle', ['id' => $membershipType->id]), $params); } self::createMembershipPriceField($params, $previousID, $membershipType->id); // update all price field value for quick config when membership type is set CRM-11718 - if ($membershipTypeId) { - self::updateAllPriceFieldValue($membershipTypeId, $params); + if ($membershipTypeID) { + self::updateAllPriceFieldValue($membershipTypeID, $params); } CRM_Utils_Hook::post($hook, 'MembershipType', $membershipType->id, $membershipType); -- 2.25.1