You are here

function wf_civicrm_api in Webform CiviCRM Integration 7.5

Same name and namespace in other branches
  1. 7.3 webform_civicrm_utils.inc \wf_civicrm_api()
  2. 7.4 includes/utils.inc \wf_civicrm_api()

Wrapper for all CiviCRM API calls For consistency, future-proofing, and error handling

Parameters

string $entity: API entity

string $operation: API operation

array $params: API params

Return value

array Result of API call

49 calls to wf_civicrm_api()
webform_civicrm_update_6205 in ./webform_civicrm.install
Upgrade for CiviCRM 4.1 compatibility.
webform_civicrm_update_7300 in ./webform_civicrm.install
Note: There are differences in how contact references and relationships work in the 3.x branch. Read the upgrade instructions at http://drupal.org/node/1615380
webform_civicrm_webform_autocomplete_options_alter in ./webform_civicrm.module
Implements hook_webform_autocomplete_options()
wf_crm_admin_form::buildContributionTab in includes/wf_crm_admin_form.inc
Contribution settings
wf_crm_admin_form::filterCaseSets in includes/wf_crm_admin_form.inc
Adjust case role fields to match creator/manager settings for a given case type

... See full list

File

includes/utils.inc, line 1646
Webform CiviCRM module's common utility functions.

Code

function wf_civicrm_api($entity, $operation, $params) {
  if (!$entity) {
    return [];
  }
  $params += [
    'check_permissions' => FALSE,
    'version' => 3,
  ];
  $result = civicrm_api($entity, $operation, $params);

  // I guess we want silent errors for getoptions b/c we check it for failure separately
  if (!empty($result['is_error']) && $operation != 'getoptions') {
    $bt = debug_backtrace();
    $n = $bt[0]['function'] == 'wf_civicrm_api' ? 1 : 0;
    $file = explode('/', $bt[$n]['file']);
    if (isset($params['credit_card_number'])) {
      $params['credit_card_number'] = "xxxxxxxxxxxx" . substr($params['credit_card_number'], -4);
    }
    watchdog('webform_civicrm', 'The CiviCRM "%function" API returned the error: "%msg" when called by function "!fn" on line !line of !file with parameters: "!params"', [
      '%function' => $entity . ' ' . $operation,
      '%msg' => $result['error_message'],
      '!fn' => $bt[$n + 1]['function'],
      '!line' => $bt[$n]['line'],
      '!file' => array_pop($file),
      '!params' => print_r($params, TRUE),
    ], WATCHDOG_ERROR);
  }
  return $result;
}