From c1fd0d7faccc32a7013fd0155382b4c2d6777cee Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Mon, 20 Mar 2023 09:54:15 +1300 Subject: [PATCH] [REF] Simplify import preProcess --- CRM/Contact/Import/Form/MapField.php | 3 +-- CRM/Import/Form/MapField.php | 8 +++++++- CRM/Import/Forms.php | 13 ------------- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/CRM/Contact/Import/Form/MapField.php b/CRM/Contact/Import/Form/MapField.php index c6c07ff0cc..d64617b4be 100644 --- a/CRM/Contact/Import/Form/MapField.php +++ b/CRM/Contact/Import/Form/MapField.php @@ -73,7 +73,7 @@ class CRM_Contact_Import_Form_MapField extends CRM_Import_Form_MapField { * @throws \Civi\API\Exception\UnauthorizedException */ public function preProcess(): void { - $this->_mapperFields = $this->getAvailableFields(); + parent::preProcess(); //format custom field names, CRM-2676 $contactType = $this->getContactType(); @@ -100,7 +100,6 @@ class CRM_Contact_Import_Form_MapField extends CRM_Import_Form_MapField { $formattedFieldNames = $this->formatCustomFieldName($this->_mapperFields); $this->_formattedFieldNames[$contactType] = $this->_mapperFields = array_merge($this->_mapperFields, $formattedFieldNames); - $this->assignMapFieldVariables(); } /** diff --git a/CRM/Import/Form/MapField.php b/CRM/Import/Form/MapField.php index 456be759fb..1fe79eace0 100644 --- a/CRM/Import/Form/MapField.php +++ b/CRM/Import/Form/MapField.php @@ -57,9 +57,15 @@ abstract class CRM_Import_Form_MapField extends CRM_Import_Forms { /** * Shared preProcess code. + * + * @throws \CRM_Core_Exception */ public function preProcess() { - $this->assignMapFieldVariables(); + $this->addExpectedSmartyVariables(['highlightedRelFields', 'initHideBoxes']); + $this->assign('columnNames', $this->getColumnHeaders()); + $this->assign('showColumnNames', $this->getSubmittedValue('skipColumnHeader') || $this->getSubmittedValue('dataSource') !== 'CRM_Import_DataSource'); + $this->assign('highlightedFields', $this->getHighlightedFields()); + $this->assign('dataValues', array_values($this->getDataRows([], 2))); $this->_mapperFields = $this->getAvailableFields(); asort($this->_mapperFields); parent::preProcess(); diff --git a/CRM/Import/Forms.php b/CRM/Import/Forms.php index 7b7ccac34c..f7aec5cb26 100644 --- a/CRM/Import/Forms.php +++ b/CRM/Import/Forms.php @@ -679,19 +679,6 @@ class CRM_Import_Forms extends CRM_Core_Form { return $mapper; } - /** - * Assign variables required for the MapField form. - * - * @throws \CRM_Core_Exception - */ - protected function assignMapFieldVariables(): void { - $this->addExpectedSmartyVariables(['highlightedRelFields', 'initHideBoxes']); - $this->assign('columnNames', $this->getColumnHeaders()); - $this->assign('showColumnNames', $this->getSubmittedValue('skipColumnHeader') || $this->getSubmittedValue('dataSource') !== 'CRM_Import_DataSource'); - $this->assign('highlightedFields', $this->getHighlightedFields()); - $this->assign('dataValues', array_values($this->getDataRows([], 2))); - } - /** * Get the fields to be highlighted in the UI. * -- 2.25.1