diff --git a/CRM/Contact/Import/Form/Preview.php b/CRM/Contact/Import/Form/Preview.php index 9f03057aee7e..3bf15b4ea251 100644 --- a/CRM/Contact/Import/Form/Preview.php +++ b/CRM/Contact/Import/Form/Preview.php @@ -241,33 +241,15 @@ public function postProcess() { $importJob->isComplete(); } - /** - * Get the mapped fields as an array of labels. - * - * e.g - * ['First Name', 'Employee Of - First Name', 'Home - Street Address'] - * - * @return array - * @throws \API_Exception - * @throws \CRM_Core_Exception - */ - protected function getMappedFieldLabels(): array { - $mapper = []; - $parser = new CRM_Contact_Import_Parser_Contact(); - $parser->setUserJobID($this->getUserJobID()); - foreach ($this->getSubmittedValue('mapper') as $columnNumber => $mappedField) { - $mapper[$columnNumber] = $parser->getMappedFieldLabel($parser->getMappingFieldFromMapperInput($mappedField, 0, $columnNumber)); - } - return $mapper; - } - /** * @return \CRM_Contact_Import_Parser_Contact */ protected function getParser(): CRM_Contact_Import_Parser_Contact { - $parser = new CRM_Contact_Import_Parser_Contact(); - $parser->setUserJobID($this->getUserJobID()); - return $parser; + if (!$this->parser) { + $this->parser = new CRM_Contact_Import_Parser_Contact(); + $this->parser->setUserJobID($this->getUserJobID()); + } + return $this->parser; } } diff --git a/CRM/Import/Forms.php b/CRM/Import/Forms.php index 1262fa0e36a8..6c61172567b3 100644 --- a/CRM/Import/Forms.php +++ b/CRM/Import/Forms.php @@ -567,4 +567,23 @@ protected function getParser() { return NULL; } + /** + * Get the mapped fields as an array of labels. + * + * e.g + * ['First Name', 'Employee Of - First Name', 'Home - Street Address'] + * + * @return array + * @throws \API_Exception + * @throws \CRM_Core_Exception + */ + protected function getMappedFieldLabels(): array { + $mapper = []; + $parser = $this->getParser(); + foreach ($this->getSubmittedValue('mapper') as $columnNumber => $mappedField) { + $mapper[$columnNumber] = $parser->getMappedFieldLabel($parser->getMappingFieldFromMapperInput($mappedField, 0, $columnNumber)); + } + return $mapper; + } + }