From e6c8711b7d917347e12f684e51a49f283678220c Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Sat, 16 Apr 2022 09:58:23 +1200 Subject: [PATCH 1/2] Update parser class name See https://github.com/civicrm/civicrm-core/pull/23227 --- .../CRM/Hrjobcontract/Import/Form/PreviewBaseClass.php | 2 +- .../CRM/Hrjobcontract/Import/Form/SummaryBaseClass.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hrjobcontract/CRM/Hrjobcontract/Import/Form/PreviewBaseClass.php b/hrjobcontract/CRM/Hrjobcontract/Import/Form/PreviewBaseClass.php index 0ef1c8f7301..0753d3cf191 100644 --- a/hrjobcontract/CRM/Hrjobcontract/Import/Form/PreviewBaseClass.php +++ b/hrjobcontract/CRM/Hrjobcontract/Import/Form/PreviewBaseClass.php @@ -46,7 +46,7 @@ class CRM_Hrjobcontract_Import_Form_Previewbaseclass extends CRM_Import_Form_Pre * manefestations * @var unknown */ - protected $_importParserUrl = '&parser=CRM_Event_Import_Parser'; + protected $_importParserUrl = '&parser=CRM_Event_Import_Parser_Participant'; /** * Function to set variables up before form is built * diff --git a/hrjobcontract/CRM/Hrjobcontract/Import/Form/SummaryBaseClass.php b/hrjobcontract/CRM/Hrjobcontract/Import/Form/SummaryBaseClass.php index e06efb2ae45..ab5b261a221 100644 --- a/hrjobcontract/CRM/Hrjobcontract/Import/Form/SummaryBaseClass.php +++ b/hrjobcontract/CRM/Hrjobcontract/Import/Form/SummaryBaseClass.php @@ -45,7 +45,7 @@ class CRM_Hrjobcontract_Import_Form_SummaryBaseClass extends CRM_Import_Form_Sum * manefestations * @var unknown */ - protected $_importParserUrl = '&parser=CRM_Event_Import_Parser'; + protected $_importParserUrl = '&parser=CRM_Event_Import_Parser_Participant'; /** * Function to set variables up before form is built * From c790c4058493792669a92ada5a8faa0db6af763e Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Wed, 10 Aug 2022 14:39:06 +1200 Subject: [PATCH 2/2] Add function being removed from core --- .../CRM/Hrjobroles/Import/Form/DataSource.php | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/com.civicrm.hrjobroles/CRM/Hrjobroles/Import/Form/DataSource.php b/com.civicrm.hrjobroles/CRM/Hrjobroles/Import/Form/DataSource.php index a11620f632c..5b2cb45bad3 100644 --- a/com.civicrm.hrjobroles/CRM/Hrjobroles/Import/Form/DataSource.php +++ b/com.civicrm.hrjobroles/CRM/Hrjobroles/Import/Form/DataSource.php @@ -76,4 +76,39 @@ public function postProcess() { $this->submitFileForMapping('CRM_Hrjobroles_Import_Parser_HrJobRoles'); } + + /** + * Common form postProcess. + * @deprecated - just use postProcess. + * + * @param string $parserClassName + * @param string|null $entity + * Entity to set for paraser currently only for custom import + */ + protected function submitFileForMapping($parserClassName, $entity = NULL) { + CRM_Core_Session::singleton()->set('dateTypes', $this->getSubmittedValue('dateFormats')); + $this->processDatasource(); + + $mapper = []; + + $parser = new $parserClassName($mapper); + if ($entity) { + $parser->setEntity($this->get($entity)); + } + $parser->setMaxLinesToProcess(100); + $parser->setUserJobID($this->getUserJobID()); + $parser->run( + $this->getSubmittedValue('uploadFile'), + $this->getSubmittedValue('fieldSeparator'), + [], + $this->getSubmittedValue('skipColumnHeader'), + CRM_Import_Parser::MODE_MAPFIELD, + $this->getSubmittedValue('contactType') + ); + + // add all the necessary variables to the form + $parser->set($this); + $this->controller->resetPage('MapField'); + } + }