$this->controller->resetPage($this->_name);
return;
}
+ $this->updateUserJobMetadata('submitted_values', $this->getSubmittedValues());
- $mapperKeys = [];
$mapper = [];
$mapperKeys = $this->controller->exportValue($this->_name, 'mapper');
$mapperKeysMain = [];
}
$parser = new CRM_Activity_Import_Parser_Activity($mapperKeysMain);
+ $parser->setUserJobID($this->getUserJobID());
$parser->run($this->getSubmittedValue('uploadFile'), $this->getSubmittedValue('fieldSeparator'), $mapper, $this->getSubmittedValue('skipColumnHeader'),
CRM_Import_Parser::MODE_PREVIEW
);
}
$parser = new CRM_Activity_Import_Parser_Activity($mapperKeys);
-
+ $parser->setUserJobID($this->getUserJobID());
$mapFields = $this->get('fields');
foreach ($mapper as $key => $value) {
/**
* This class delegates to the chosen DataSource to grab the data to be imported.
*/
-class CRM_Contact_Import_Form_DataSource extends CRM_Import_Forms {
+class CRM_Contact_Import_Form_DataSource extends CRM_Import_Form_DataSource {
/**
* Get any smarty elements that may not be present in the form.
*/
public function postProcess() {
$this->controller->resetPage('MapField');
- if (!$this->getUserJobID()) {
- $this->createUserJob();
- }
- else {
- $this->flushDataSource();
- $this->updateUserJobMetadata('submitted_values', $this->getSubmittedValues());
- }
-
+ $this->processDatasource();
// @todo - this params are being set here because they were / possibly still
// are in some places being accessed by forms later in the flow
// ie CRM_Contact_Import_Form_MapField, CRM_Contact_Import_Form_Preview
}
CRM_Core_Session::singleton()->set('dateTypes', $storeParams['dateFormats']);
- $this->instantiateDataSource();
- }
-
- /**
- * Instantiate the datasource.
- *
- * This gives the datasource a chance to do any table creation etc.
- *
- * @throws \API_Exception
- * @throws \CRM_Core_Exception
- */
- private function instantiateDataSource(): void {
- $this->getDataSourceObject()->initialize();
}
/**
}
$parser = new CRM_Contribute_Import_Parser_Contribution($mapperKeys, $mapperSoftCredit, $mapperPhoneType, $mapperSoftCreditType);
-
+ $parser->setUserJobID($this->getUserJobID());
$mapFields = $this->get('fields');
foreach ($mapper as $key => $value) {
}
$parser = new $this->_parser($mapperKeys);
+ $parser->setUserJobID($this->getUserJobID());
$parser->setEntity($entity);
$mapFields = $this->get('fields');
}
$parser = new CRM_Event_Import_Parser_Participant($mapperKeys);
-
+ $parser->setUserJobID($this->getUserJobID());
$mapFields = $this->get('fields');
foreach ($mapper as $key => $value) {
protected function submitFileForMapping($parserClassName, $entity = NULL) {
$this->controller->resetPage('MapField');
CRM_Core_Session::singleton()->set('dateTypes', $this->getSubmittedValue('dateFormats'));
- if (!$this->getUserJobID()) {
- $this->createUserJob();
- }
- else {
- $this->updateUserJobMetadata('submitted_values', $this->getSubmittedValues());
- }
+ $this->processDatasource();
$mapper = [];
return ts('Upload Data');
}
+ /**
+ * Process the datasource submission - setting up the job and data source.
+ *
+ * @throws \API_Exception
+ * @throws \CRM_Core_Exception
+ */
+ protected function processDatasource(): void {
+ if (!$this->getUserJobID()) {
+ $this->createUserJob();
+ }
+ else {
+ $this->flushDataSource();
+ $this->updateUserJobMetadata('submitted_values', $this->getSubmittedValues());
+ }
+ $this->instantiateDataSource();
+ }
+
+ /**
+ * Instantiate the datasource.
+ *
+ * This gives the datasource a chance to do any table creation etc.
+ *
+ * @throws \API_Exception
+ * @throws \CRM_Core_Exception
+ */
+ private function instantiateDataSource(): void {
+ $this->getDataSourceObject()->initialize();
+ }
+
}