bug fix
provide TwingleEvent campaign id for instantiation
This commit is contained in:
parent
d031c82f31
commit
aef0297daf
3 changed files with 11 additions and 7 deletions
|
@ -96,11 +96,17 @@ function _civicrm_api3_twingle_event_Getsingle_spec(array &$spec) {
|
|||
* @see civicrm_api3_create_success
|
||||
*/
|
||||
function civicrm_api3_twingle_event_Getsingle(array $params): array {
|
||||
|
||||
$returnValues = civicrm_api3('TwingleEvent', 'get', $params);
|
||||
$count = $returnValues['count'];
|
||||
|
||||
if ($count != 1) {
|
||||
return civicrm_api3_create_error("Expected one TwingleEvent but found $count");
|
||||
}
|
||||
return civicrm_api3_create_success($returnValues['values'], $params, 'TwingleEvent', 'Getsingle');
|
||||
return civicrm_api3_create_success(
|
||||
$returnValues['values'][$returnValues['id']],
|
||||
$params,
|
||||
'TwingleEvent',
|
||||
'Getsingle'
|
||||
);
|
||||
}
|
||||
|
|
|
@ -256,7 +256,7 @@ 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, $event_from_civicrm['id']);
|
||||
|
||||
// sync event
|
||||
$result = _eventSync($event, $event_from_twingle, $twingleApi, $params);
|
||||
|
@ -298,13 +298,14 @@ function civicrm_api3_twingle_event_Sync(array $params): array {
|
|||
* # Instantiates a TwingleEvent
|
||||
*
|
||||
* @param $values
|
||||
* @param null $id
|
||||
*
|
||||
* @return \CRM_TwingleCampaign_BAO_TwingleEvent
|
||||
* @throws \CiviCRM_API3_Exception
|
||||
*/
|
||||
function _instantiateEvent($values): CRM_TwingleCampaign_BAO_TwingleEvent {
|
||||
function _instantiateEvent($values, $id = NULL): CRM_TwingleCampaign_BAO_TwingleEvent {
|
||||
try {
|
||||
return new TwingleEvent($values, $values['id']);
|
||||
return new TwingleEvent($values, $id);
|
||||
} catch (Exception $e) {
|
||||
throw new CiviCRM_API3_Exception(
|
||||
$e->getMessage(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue