From cd595befc75758599836a1ecbf9d14a8374a87bd Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 11 Dec 2020 09:48:35 +1300 Subject: [PATCH] Switch to non-static functions I realise these functions are static so that the formRule can call them - but the formRule has access to the form object and the intention was obviously always that the formRule can call functions on the form. This cleans that up: --- CRM/Member/Form.php | 12 ++++++------ CRM/Member/Form/Membership.php | 4 ++-- CRM/Member/Form/MembershipRenewal.php | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CRM/Member/Form.php b/CRM/Member/Form.php index 3ae6973ef5..c2c4dfa871 100644 --- a/CRM/Member/Form.php +++ b/CRM/Member/Form.php @@ -416,7 +416,7 @@ class CRM_Member_Form extends CRM_Contribute_Form_AbstractEditPayment { * * @return array */ - protected static function getPriceSetDetails($params) { + protected function getPriceSetDetails(array $params): ?array { $priceSetID = $params['price_set_id'] ?? NULL; if ($priceSetID) { return CRM_Price_BAO_PriceSet::getSetDetail($priceSetID); @@ -436,10 +436,10 @@ class CRM_Member_Form extends CRM_Contribute_Form_AbstractEditPayment { * * @return int */ - protected static function getPriceSetID($params) { + protected function getPriceSetID(array $params): int { $priceSetID = $params['price_set_id'] ?? NULL; if (!$priceSetID) { - $priceSetDetails = self::getPriceSetDetails($params); + $priceSetDetails = $this->getPriceSetDetails($params); return (int) key($priceSetDetails); } return (int) $priceSetID; @@ -452,9 +452,9 @@ class CRM_Member_Form extends CRM_Contribute_Form_AbstractEditPayment { * * @return array */ - protected function setPriceSetParameters($formValues) { - $this->_priceSetId = self::getPriceSetID($formValues); - $priceSetDetails = self::getPriceSetDetails($formValues); + protected function setPriceSetParameters(array $formValues): array { + $this->_priceSetId = $this->getPriceSetID($formValues); + $priceSetDetails = $this->getPriceSetDetails($formValues); $this->_priceSet = $priceSetDetails[$this->_priceSetId]; // process price set and get total amount and line items. $this->ensurePriceParamsAreSet($formValues); diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php index b5846d2177..642079722a 100644 --- a/CRM/Member/Form/Membership.php +++ b/CRM/Member/Form/Membership.php @@ -651,8 +651,8 @@ DESC limit 1"); public static function formRule($params, $files, $self) { $errors = []; - $priceSetId = self::getPriceSetID($params); - $priceSetDetails = self::getPriceSetDetails($params); + $priceSetId = $self->getPriceSetID($params); + $priceSetDetails = $self->getPriceSetDetails($params); $selectedMemberships = self::getSelectedMemberships($priceSetDetails[$priceSetId], $params); diff --git a/CRM/Member/Form/MembershipRenewal.php b/CRM/Member/Form/MembershipRenewal.php index dcf50ec085..6abca4299d 100644 --- a/CRM/Member/Form/MembershipRenewal.php +++ b/CRM/Member/Form/MembershipRenewal.php @@ -782,7 +782,7 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form { protected function getOrderParams(): array { $order = new CRM_Financial_BAO_Order(); $order->setPriceSelectionFromUnfilteredInput($this->_params); - $order->setPriceSetID(self::getPriceSetID($this->_params)); + $order->setPriceSetID($this->getPriceSetID($this->_params)); $order->setOverrideTotalAmount($this->_params['total_amount']); $order->setOverrideFinancialTypeID((int) $this->_params['financial_type_id']); return [ -- 2.25.1