3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * This class allows datasource specific fields to be added to the datasource form.
21 class CRM_Import_Form_DataSourceConfig
extends CRM_Import_Forms
{
24 * Set variables up before form is built.
26 * @throws \CRM_Core_Exception
28 public function preProcess(): void
{
29 $dataSourcePath = explode('_', $this->getDataSourceClassName());
30 $templateFile = 'CRM/Contact/Import/Form/' . $dataSourcePath[3] . '.tpl';
31 $this->assign('dataSourceFormTemplateFile', $templateFile ??
NULL);
32 if (CRM_Utils_Request
::retrieveValue('user_job_id', 'Integer')) {
33 $this->setUserJobID(CRM_Utils_Request
::retrieveValue('user_job_id', 'Integer'));
38 * Build the form object.
40 * @throws \CRM_Core_Exception
42 public function buildQuickForm(): void
{
43 $this->buildDataSourceFields();
51 * @throws \API_Exception
52 * @throws \CRM_Core_Exception
54 public function setDefaultValues() {
56 if ($this->userJobID
) {
57 foreach ($this->getDataSourceFields() as $fieldName) {
58 $defaults[$fieldName] = $this->getSubmittedValue($fieldName);
65 * Get the submitted value, as saved in the user job.
67 * This form is not in the same flow as the DataSource but
68 * the value we want is saved to the userJob so load it from there.
70 * @param string $fieldName
73 * @throws \API_Exception
75 public function getSubmittedValue(string $fieldName) {
76 $userJob = $this->getUserJob();
77 return $userJob['metadata']['submitted_values'][$fieldName];