diff --git a/CRM/TwingleCampaign/BAO/Campaign.php b/CRM/TwingleCampaign/BAO/Campaign.php
index 70a0ee3..045124a 100644
--- a/CRM/TwingleCampaign/BAO/Campaign.php
+++ b/CRM/TwingleCampaign/BAO/Campaign.php
@@ -171,6 +171,7 @@ abstract class CRM_TwingleCampaign_BAO_Campaign {
* Deactivate all duplicates of a campaign but the newest one
*
* @param array $result
+ *
* @throws CiviCRM_API3_Exception
*/
protected function handleDuplicates(array &$result) {
@@ -201,30 +202,7 @@ abstract class CRM_TwingleCampaign_BAO_Campaign {
*
* @throws Exception
*/
- public function translateKeys(array &$values, string $direction) {
-
- // Get translations for fields
- $field_translations = Cache::getInstance()
- ->getTranslations()[$this->className];
-
- // Set the direction of the translation
- if ($direction == self::OUT) {
- $field_translations = array_flip($field_translations);
- }
- // Throw error if $direction constant does not match IN or OUT
- elseif ($direction != self::IN) {
- throw new Exception(
- "Invalid Parameter $direction for translateKeys()"
- );
- // TODO: use specific exception or create own
- }
-
- // Translate keys
- foreach ($field_translations as $origin => $translation) {
- $values[$translation] = $values[$origin];
- unset($values[$origin]);
- }
- }
+ public static abstract function translateKeys(array &$values, string $direction);
/**
diff --git a/CRM/TwingleCampaign/BAO/TwingleEvent.php b/CRM/TwingleCampaign/BAO/TwingleEvent.php
index c16f9d2..efa630a 100644
--- a/CRM/TwingleCampaign/BAO/TwingleEvent.php
+++ b/CRM/TwingleCampaign/BAO/TwingleEvent.php
@@ -292,6 +292,45 @@ class CRM_TwingleCampaign_BAO_TwingleEvent extends Campaign {
}
}
+ /**
+ * Translate array keys between CiviCRM Campaigns and Twingle
+ *
+ * @param array $values
+ * array of which keys shall be translated
+ *
+ * @param string $direction
+ * Campaign::IN -> translate array keys from Twingle format into
+ * CiviCRM format
+ * Campaign::OUT -> translate array keys from CiviCRM format into
+ * Twingle format
+ *
+ * @throws Exception
+ */
+ public static function translateKeys(array &$values, string $direction) {
+
+ // Get translations for fields
+ $field_translations = Cache::getInstance()
+ ->getTranslations()['TwingleEvent'];
+
+ // Set the direction of the translation
+ if ($direction == self::OUT) {
+ $field_translations = array_flip($field_translations);
+ }
+ // Throw error if $direction constant does not match IN or OUT
+ elseif ($direction != self::IN) {
+ throw new Exception(
+ "Invalid Parameter $direction for translateKeys()"
+ );
+ // TODO: use specific exception or create own
+ }
+
+ // Translate keys
+ foreach ($field_translations as $origin => $translation) {
+ $values[$translation] = $values[$origin];
+ unset($values[$origin]);
+ }
+ }
+
/**
* Get a response that describes the status of a TwingleEvent
diff --git a/CRM/TwingleCampaign/BAO/TwingleProject.php b/CRM/TwingleCampaign/BAO/TwingleProject.php
index 16ce5cb..c90c693 100644
--- a/CRM/TwingleCampaign/BAO/TwingleProject.php
+++ b/CRM/TwingleCampaign/BAO/TwingleProject.php
@@ -321,6 +321,45 @@ class CRM_TwingleCampaign_BAO_TwingleProject extends Campaign {
}
}
+ /**
+ * Translate array keys between CiviCRM Campaigns and Twingle
+ *
+ * @param array $values
+ * array of which keys shall be translated
+ *
+ * @param string $direction
+ * Campaign::IN -> translate array keys from Twingle format into
+ * CiviCRM format
+ * Campaign::OUT -> translate array keys from CiviCRM format into
+ * Twingle format
+ *
+ * @throws Exception
+ */
+ public static function translateKeys(array &$values, string $direction) {
+
+ // Get translations for fields
+ $field_translations = Cache::getInstance()
+ ->getTranslations()['TwingleProject'];
+
+ // Set the direction of the translation
+ if ($direction == self::OUT) {
+ $field_translations = array_flip($field_translations);
+ }
+ // Throw error if $direction constant does not match IN or OUT
+ elseif ($direction != self::IN) {
+ throw new Exception(
+ "Invalid Parameter $direction for translateKeys()"
+ );
+ // TODO: use specific exception or create own
+ }
+
+ // Translate keys
+ foreach ($field_translations as $origin => $translation) {
+ $values[$translation] = $values[$origin];
+ unset($values[$origin]);
+ }
+ }
+
/**
* Set embed data fields