update get API

This commit is contained in:
Marc Michalsky forumZFD 2020-09-29 08:59:16 +02:00
parent 12d31e300f
commit 209fe29c92
Signed by untrusted user who does not match committer: marc.koch
GPG key ID: 12406554CFB028B9

View file

@ -50,14 +50,17 @@ function civicrm_api3_twingle_sync_Get($params) {
$apiKey = empty($params['twingle_api_key'])
? CRM_Core_BAO_Setting::getItem('', 'twingle_api_key')
: $params['twingle_api_key'];
$twingleApi = new TwingleApiCall($apiKey);
// Get all projects from Twingle and store them in $projects
$projects = $twingleApi->getProject();
// Create projects as campaigns if they do not exist and store results in
$result_values['projects'] = $twingleApi->getProject();
foreach ($result_values['projects'] as $project) {
// $result_values
$i = 0;
foreach ($projects as $project) {
if (is_array($project)) {
$result_values['campaigns_created'][$project['id']] = $twingleApi->createProject($project);
$result_values['sync']['projects'][$i++] = $twingleApi->syncProject($project);
}
}