use cusom field mapping instead of static custom field array
This commit is contained in:
parent
746ed45f04
commit
5d597de5de
1 changed files with 5 additions and 18 deletions
|
@ -20,13 +20,11 @@ class TwingleProject {
|
||||||
|
|
||||||
private $values;
|
private $values;
|
||||||
|
|
||||||
private $orig_values;
|
|
||||||
|
|
||||||
private $timestamp;
|
private $timestamp;
|
||||||
|
|
||||||
private $settings;
|
private $settings;
|
||||||
|
|
||||||
private static $customFields = [];
|
private static $customFieldMapping;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TwingleProject constructor.
|
* TwingleProject constructor.
|
||||||
|
@ -42,23 +40,9 @@ class TwingleProject {
|
||||||
// Format data types of the values for import into CiviCRM
|
// Format data types of the values for import into CiviCRM
|
||||||
$this->formatForImport($values);
|
$this->formatForImport($values);
|
||||||
|
|
||||||
// Add necessary attributes
|
// Fetch custom field mapping once
|
||||||
$this->values['title'] = $values['name'];
|
|
||||||
$this->values['campaign_type_id'] = 'twingle_project';
|
|
||||||
|
|
||||||
// Fetch custom fields once and store them in static attribute
|
|
||||||
self::init();
|
self::init();
|
||||||
|
|
||||||
// Copy values
|
|
||||||
$this->orig_values = $values;
|
|
||||||
|
|
||||||
// Map parameters to custom field names (e.g. "custom_21")
|
|
||||||
foreach (self::$customFields as $customField) {
|
|
||||||
if (!empty($values[str_replace('twingle_project_', '', $customField->getName())])) {
|
|
||||||
$this->values['custom_' . $customField->getId()] =
|
|
||||||
$values[str_replace('twingle_project_', '', $customField->getName())];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -72,6 +56,9 @@ class TwingleProject {
|
||||||
if (self::$bInitialized) {
|
if (self::$bInitialized) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
self::$customFieldMapping = CustomField::getMapping();
|
||||||
|
self::$bInitialized = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
$json_file = file_get_contents(E::path() .
|
$json_file = file_get_contents(E::path() .
|
||||||
'/CRM/TwingleCampaign/Upgrader/resources/campaigns.json');
|
'/CRM/TwingleCampaign/Upgrader/resources/campaigns.json');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue