From eb07c5cf730ee8ddd407583d82d355d8e9f498d1 Mon Sep 17 00:00:00 2001 From: Marc Michalsky forumZFD Date: Thu, 11 Feb 2021 18:43:53 +0100 Subject: [PATCH] improve TwingleCampaign.getResponse() --- CRM/TwingleCampaign/BAO/TwingleCampaign.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/CRM/TwingleCampaign/BAO/TwingleCampaign.php b/CRM/TwingleCampaign/BAO/TwingleCampaign.php index 728efd0..c7db9b6 100644 --- a/CRM/TwingleCampaign/BAO/TwingleCampaign.php +++ b/CRM/TwingleCampaign/BAO/TwingleCampaign.php @@ -311,18 +311,16 @@ class CRM_TwingleCampaign_BAO_TwingleCampaign { */ public function getResponse(string $status = NULL): array { - $response = [ - 'id' => (int) $this->id, - ]; + $keys = ['id', 'name', 'title', 'parent_project_id', 'parent_id', 'cid', 'url']; + $response = []; + foreach ($keys as $key) { + if (isset($this->values[$key])) { + $response[$key] = $this->values[$key]; + } + } if ($status) { $response['status'] = $status; } - if (isset($this->values['title'])) { - $response['title'] = $this->values['title']; - } - if (isset($this->values['parent_project_id'])) { - $response['parent_project_id'] = (int) $this->values['parent_project_id']; - } return $response; }