improve TwingleCampaign.getResponse()

This commit is contained in:
Marc Michalsky forumZFD 2021-02-11 18:43:53 +01:00
parent dc4d5a697c
commit eb07c5cf73
Signed by untrusted user who does not match committer: marc.koch
GPG key ID: 12406554CFB028B9

View file

@ -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;
}