use inheritance for campaign classes

This commit is contained in:
Marc Michalsky forumZFD 2020-10-29 23:14:18 +01:00
parent 24d224cc38
commit 6b434e455f
Signed by untrusted user who does not match committer: marc.koch
GPG key ID: 12406554CFB028B9
10 changed files with 932 additions and 475 deletions

View file

@ -55,7 +55,7 @@ function civicrm_api3_twingle_sync_Post($params) {
: $params['twingle_api_key'];
$twingleApi = new TwingleApiCall($apiKey);
// Get all projects from Twingle and store them in $projects
// Get all projects from Twingle
$projects = $twingleApi->getProject();
// Create projects as campaigns if they do not exist and store results in
@ -68,5 +68,22 @@ function civicrm_api3_twingle_sync_Post($params) {
}
}
// Get all events from projects of event type
foreach ($result_values['sync']['projects'] as $project) {
if ($project['project_type'] == 'event') {
$events = $twingleApi->getEvent($project['project_id']);
}
}
// Create events them as campaigns if they do not exist and store results in
// $result_values
$j = 0;
if ($events) {
foreach ($events as $event) {
$result_values['sync']['events'][$j++] = $twingleApi
->syncEvent($event, $is_test);
}
}
return civicrm_api3_create_success($result_values);
}