[#4] (wip) Process custom fields parameter

This commit is contained in:
Jens Schuppe 2019-08-05 16:34:35 +02:00
parent 4537ac540a
commit 73481fb7ed
3 changed files with 78 additions and 0 deletions

View file

@ -69,6 +69,20 @@ class CRM_Twingle_Profile {
return in_array($project_id, $project_ids);
}
/**
* @return array
* The profile's configured custom field mapping
*/
public function getCustomFieldMapping() {
$custom_field_mapping = array();
if (!empty($custom_field_definition = $this->getAttribute('custom_field_mapping'))) {
foreach (preg_split('/\r\n|\r|\n/', $custom_field_definition, -1, PREG_SPLIT_NO_EMPTY) as $twingle_field_name => $custom_field_name) {
$custom_field_mapping[$twingle_field_name] = $custom_field_name;
}
}
return $custom_field_mapping;
}
/**
* Retrieves all data attributes of the profile.
*
@ -191,6 +205,7 @@ class CRM_Twingle_Profile {
'donation_receipt_groups',
'campaign',
'contribution_source',
'custom_field_mapping',
);
}
@ -250,6 +265,7 @@ class CRM_Twingle_Profile {
'donation_receipt_groups' => NULL,
'campaign' => NULL,
'contribution_source' => NULL,
'custom_field_mapping' => NULL,
));
}