This commit is contained in:
Marc Michalsky forumZFD 2020-09-29 16:14:49 +02:00
parent 0ce48fa58b
commit bbca822f15
Signed by untrusted user who does not match committer: marc.koch
GPG key ID: 12406554CFB028B9

View file

@ -179,6 +179,15 @@ class TwingleProject {
} }
} }
/**
* Instantiate an existing project by campaign id
*
* @param $id
*
* @return \CRM\TwingleCampaign\Models\TwingleProject
* @throws \CiviCRM_API3_Exception
* @throws \Exception
*/
public static function fetch($id) { public static function fetch($id) {
$result = civicrm_api3('Campaign', 'getsingle', [ $result = civicrm_api3('Campaign', 'getsingle', [
'sequential' => 1, 'sequential' => 1,
@ -222,6 +231,7 @@ class TwingleProject {
*/ */
private function translateValues($rev = FALSE) { private function translateValues($rev = FALSE) {
$values = []; $values = [];
// Translate from field name to custom field name
if (!$rev) { if (!$rev) {
foreach (TwingleProject::$customFieldMapping as $field => $custom) { foreach (TwingleProject::$customFieldMapping as $field => $custom) {
if (array_key_exists( if (array_key_exists(
@ -236,6 +246,7 @@ class TwingleProject {
} }
} }
} }
// Translate from custom field name to field name
else { else {
foreach (TwingleProject::$customFieldMapping as $field => $custom) { foreach (TwingleProject::$customFieldMapping as $field => $custom) {
if (array_key_exists($custom, $this->values) if (array_key_exists($custom, $this->values)
@ -360,6 +371,4 @@ class TwingleProject {
} }
} }