Skip to content

Commit

Permalink
Merge pull request #23592 from eileenmcnaughton/import_parent
Browse files Browse the repository at this point in the history
[Import] [ref] Move function to parent for use by siblings
  • Loading branch information
seamuslee001 authored May 27, 2022
2 parents 006a3ca + d00da88 commit b994930
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
28 changes: 5 additions & 23 deletions CRM/Contact/Import/Form/Preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}
19 changes: 19 additions & 0 deletions CRM/Import/Forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}

0 comments on commit b994930

Please sign in to comment.