translate values in two directions

This commit is contained in:
Marc Michalsky forumZFD 2020-09-29 14:15:04 +02:00
parent cbca983d8b
commit a05b671f90
Signed by untrusted user who does not match committer: marc.koch
GPG key ID: 12406554CFB028B9

View file

@ -199,22 +199,37 @@ class TwingleProject {
*
* @return array
*/
private function translateValues() {
private function translateValues($rev = FALSE) {
$values = [];
foreach (TwingleProject::$customFieldMapping as $field => $custom) {
if (array_key_exists(
str_replace('twingle_project_', '', $field),
$this->values)
) {
$values[$custom] = $this->values[str_replace(
'twingle_project_',
'',
$field)];
if (!$rev) {
foreach (TwingleProject::$customFieldMapping as $field => $custom) {
if (array_key_exists(
str_replace('twingle_project_', '', $field),
$this->values)
) {
$values[$custom] = $this->values[str_replace(
'twingle_project_',
'',
$field
)];
}
}
}
// Add necessary attributes
$values['title'] = $this->values['name'];
else {
foreach (TwingleProject::$customFieldMapping as $field => $custom) {
if (array_key_exists($custom, $this->values)
) {
$values[str_replace(
'twingle_project_',
'',
$field
)] = $this->values[$custom];
}
}
}
// Add necessary values
$values['campaign_type_id'] = 'twingle_project';
$values['title'] = $this->values['name'];
return $values;
}