rename functions in sync apis to avoid collisions
This commit is contained in:
parent
93349804fa
commit
6e80fa7526
2 changed files with 16 additions and 16 deletions
|
@ -116,7 +116,7 @@ function civicrm_api3_twingle_event_Sync(array $params): array {
|
|||
|
||||
// instantiate event from CiviCRM
|
||||
try {
|
||||
$event = instantiateEvent($result['values'][0]);
|
||||
$event = _instantiateEvent($result['values'][0]);
|
||||
} catch (CiviCRM_API3_Exception $e) {
|
||||
Civi::log()->error(
|
||||
$e->getMessage(),
|
||||
|
@ -129,7 +129,7 @@ function civicrm_api3_twingle_event_Sync(array $params): array {
|
|||
}
|
||||
// Synchronize events
|
||||
if (!empty($event_from_twingle)) {
|
||||
return sync($event, $event_from_twingle, $twingleApi, $params);
|
||||
return _eventSync($event, $event_from_twingle, $twingleApi, $params);
|
||||
}
|
||||
|
||||
// If Twingle does not know an event with the given event_id, give error
|
||||
|
@ -213,7 +213,7 @@ function civicrm_api3_twingle_event_Sync(array $params): array {
|
|||
|
||||
// Instantiate Event
|
||||
try {
|
||||
$event = instantiateEvent($event_from_twingle);
|
||||
$event = _instantiateEvent($event_from_twingle);
|
||||
} catch (CiviCRM_API3_Exception $e) {
|
||||
Civi::log()->error(
|
||||
$e->getMessage(),
|
||||
|
@ -256,10 +256,10 @@ function civicrm_api3_twingle_event_Sync(array $params): array {
|
|||
if ($event_from_twingle['id'] == $event_from_civicrm['event_id']) {
|
||||
|
||||
// instantiate project with values from TwingleEvent.Get
|
||||
$event = instantiateEvent($event_from_civicrm);
|
||||
$event = _instantiateEvent($event_from_civicrm);
|
||||
|
||||
// sync event
|
||||
$result = sync($event, $event_from_twingle, $twingleApi, $params);
|
||||
$result = _eventSync($event, $event_from_twingle, $twingleApi, $params);
|
||||
if ($result['is_error'] != 0) {
|
||||
$errors_occurred++;
|
||||
$result_values[$event->getId()] =
|
||||
|
@ -302,7 +302,7 @@ function civicrm_api3_twingle_event_Sync(array $params): array {
|
|||
* @return \CRM_TwingleCampaign_BAO_TwingleEvent
|
||||
* @throws \CiviCRM_API3_Exception
|
||||
*/
|
||||
function instantiateEvent($values): CRM_TwingleCampaign_BAO_TwingleEvent {
|
||||
function _instantiateEvent($values): CRM_TwingleCampaign_BAO_TwingleEvent {
|
||||
try {
|
||||
return new TwingleEvent($values, $values['id']);
|
||||
} catch (Exception $e) {
|
||||
|
@ -331,7 +331,7 @@ function instantiateEvent($values): CRM_TwingleCampaign_BAO_TwingleEvent {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
function updateLocally(array $event_from_twingle,
|
||||
function _updateEventLocally(array $event_from_twingle,
|
||||
TwingleEvent $event,
|
||||
array $params,
|
||||
TwingleApiCall $twingleApi): array {
|
||||
|
@ -385,7 +385,7 @@ function updateLocally(array $event_from_twingle,
|
|||
* @return array
|
||||
* @throws \CiviCRM_API3_Exception
|
||||
*/
|
||||
function sync(TwingleEvent $event,
|
||||
function _eventSync(TwingleEvent $event,
|
||||
array $event_from_twingle,
|
||||
TwingleApiCall $twingleApi,
|
||||
array $params): array {
|
||||
|
@ -394,7 +394,7 @@ function sync(TwingleEvent $event,
|
|||
// CiviCRM TwingleEvent campaign, update the campaign on CiviCRM's side.
|
||||
// NOTE: Changes on TwingleEvents are not meant to get pushed to Twingle
|
||||
if ($event_from_twingle['updated_at'] != $event->lastUpdate()) {
|
||||
return updateLocally($event_from_twingle, $event, $params, $twingleApi);
|
||||
return _updateEventLocally($event_from_twingle, $event, $params, $twingleApi);
|
||||
}
|
||||
|
||||
// If both versions are still synchronized
|
||||
|
|
|
@ -103,7 +103,7 @@ function civicrm_api3_twingle_project_Sync(array $params): array {
|
|||
|
||||
// Synchronize projects
|
||||
if (!empty($project_from_twingle)) {
|
||||
return sync($project, $project_from_twingle, $twingleApi, $params);
|
||||
return _projectSync($project, $project_from_twingle, $twingleApi, $params);
|
||||
}
|
||||
|
||||
// If Twingle does not know a project with the given project_id, give error
|
||||
|
@ -233,7 +233,7 @@ function civicrm_api3_twingle_project_Sync(array $params): array {
|
|||
$project = new TwingleProject($project_from_civicrm, $id);
|
||||
|
||||
// sync project
|
||||
$result = sync($project, $project_from_twingle, $twingleApi, $params);
|
||||
$result = _projectSync($project, $project_from_twingle, $twingleApi, $params);
|
||||
if ($result['is_error'] != 0) {
|
||||
$errors_occurred++;
|
||||
$result_values[$project->getId()] =
|
||||
|
@ -279,7 +279,7 @@ function civicrm_api3_twingle_project_Sync(array $params): array {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
function updateLocally(array $project_from_twingle,
|
||||
function _updateProjectLocally(array $project_from_twingle,
|
||||
TwingleProject $project,
|
||||
array $params,
|
||||
TwingleApiCall $twingleApi): array {
|
||||
|
@ -331,7 +331,7 @@ function updateLocally(array $project_from_twingle,
|
|||
* @return array
|
||||
* @throws \CiviCRM_API3_Exception
|
||||
*/
|
||||
function pushToTwingle(TwingleProject $project,
|
||||
function _pushProjectToTwingle(TwingleProject $project,
|
||||
TwingleApiCall $twingleApi,
|
||||
array $params): array {
|
||||
|
||||
|
@ -418,7 +418,7 @@ function pushToTwingle(TwingleProject $project,
|
|||
* @return array
|
||||
* @throws \CiviCRM_API3_Exception
|
||||
*/
|
||||
function sync(TwingleProject $project,
|
||||
function _projectSync(TwingleProject $project,
|
||||
array $project_from_twingle,
|
||||
TwingleApiCall $twingleApi,
|
||||
array $params): array {
|
||||
|
@ -426,13 +426,13 @@ function sync(TwingleProject $project,
|
|||
// If Twingle's version of the project is newer than the CiviCRM
|
||||
// TwingleProject campaign, update the campaign
|
||||
if ($project_from_twingle['last_update'] > $project->lastUpdate()) {
|
||||
return updateLocally($project_from_twingle, $project, $params, $twingleApi);
|
||||
return _updateProjectLocally($project_from_twingle, $project, $params, $twingleApi);
|
||||
}
|
||||
|
||||
// If the CiviCRM TwingleProject campaign was changed, update the project
|
||||
// on Twingle's side
|
||||
elseif ($project_from_twingle['last_update'] < $project->lastUpdate()) {
|
||||
return pushToTwingle($project, $twingleApi, $params);
|
||||
return _pushProjectToTwingle($project, $twingleApi, $params);
|
||||
}
|
||||
|
||||
// If both versions are still synchronized
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue