Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to non-static functions #19164

Merged
merged 1 commit into from
Dec 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions CRM/Member/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ protected function ensurePriceParamsAreSet(&$formValues) {
*
* @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);
Expand All @@ -436,10 +436,10 @@ protected static function getPriceSetDetails($params) {
*
* @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;
Expand All @@ -452,9 +452,9 @@ protected static function getPriceSetID($params) {
*
* @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);
Expand Down
4 changes: 2 additions & 2 deletions CRM/Member/Form/Membership.php
Original file line number Diff line number Diff line change
Expand Up @@ -651,8 +651,8 @@ public function buildQuickForm() {
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);

Expand Down
2 changes: 1 addition & 1 deletion CRM/Member/Form/MembershipRenewal.php
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ public function processMembership($memParams, $changeToday, $numRenewTerms, $pen
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 [
Expand Down