From 24ed9b298dc1d2aa1d7b208d7e555e3a4ee72cda Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Sun, 19 Mar 2023 12:09:57 +1300 Subject: [PATCH] [REF] Minor code simplification - extract getHighlightedFields --- CRM/Contribute/Import/Form/MapField.php | 63 +++++++++++-------------- 1 file changed, 28 insertions(+), 35 deletions(-) diff --git a/CRM/Contribute/Import/Form/MapField.php b/CRM/Contribute/Import/Form/MapField.php index abc42a05b2..6721a4f836 100644 --- a/CRM/Contribute/Import/Form/MapField.php +++ b/CRM/Contribute/Import/Form/MapField.php @@ -20,41 +20,6 @@ */ class CRM_Contribute_Import_Form_MapField extends CRM_Import_Form_MapField { - /** - * Set variables up before form is built. - */ - public function preProcess() { - parent::preProcess(); - - $highlightedFields = ['financial_type_id', 'total_amount']; - //CRM-2219 removing other required fields since for updation only - //invoice id or trxn id or contribution id is required. - if ($this->isUpdateExisting()) { - //modify field title only for update mode. CRM-3245 - foreach ([ - 'contribution_id', - 'invoice_id', - 'trxn_id', - ] as $key) { - $highlightedFields[] = $key; - } - } - elseif ($this->isSkipExisting()) { - $highlightedFieldsArray = [ - 'contribution_contact_id', - 'email', - 'first_name', - 'last_name', - 'external_identifier', - ]; - foreach ($highlightedFieldsArray as $name) { - $highlightedFields[] = $name; - } - } - - $this->assign('highlightedFields', $highlightedFields); - } - /** * Should contact fields be filtered which determining fields to show. * @@ -267,4 +232,32 @@ class CRM_Contribute_Import_Form_MapField extends CRM_Import_Form_MapField { return NULL; } + /** + * @return string[] + */ + protected function getHighlightedFields(): array { + $highlightedFields = ['financial_type_id', 'total_amount']; + //CRM-2219 removing other required fields since for updating only + //invoice id or trxn id or contribution id is required. + if ($this->isUpdateExisting()) { + //modify field title only for update mode. CRM-3245 + foreach (['contribution_id', 'invoice_id', 'trxn_id'] as $key) { + $highlightedFields[] = $key; + } + } + elseif ($this->isSkipExisting()) { + $highlightedFieldsArray = [ + 'contribution_contact_id', + 'email', + 'first_name', + 'last_name', + 'external_identifier', + ]; + foreach ($highlightedFieldsArray as $name) { + $highlightedFields[] = $name; + } + } + return $highlightedFields; + } + } -- 2.25.1