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