You are here

function wf_crm_apivalues in Webform CiviCRM Integration 7.5

Same name and namespace in other branches
  1. 7.4 includes/utils.inc \wf_crm_apivalues()

Get the values from an api call

Parameters

string $entity: API entity

string $operation: API operation

array $params: API params

string $value: Reduce each result to this single value

Return value

array Values from API call

46 calls to wf_crm_apivalues()
webform_civicrm_webform_autocomplete_options_alter in ./webform_civicrm.module
Implements hook_webform_autocomplete_options()
webform_civicrm_webform_submission_load in ./webform_civicrm.module
Implements hook_webform_submission_load(). Add CiviCRM contact info to submission objects.
wf_crm_admin_form::buildActivityTab in includes/wf_crm_admin_form.inc
Activity settings
wf_crm_admin_form::buildCaseTab in includes/wf_crm_admin_form.inc
Case settings FIXME: This is exactly the same code as buildGrantTab. More utilities and less boilerplate needed.
wf_crm_admin_form::buildGrantTab in includes/wf_crm_admin_form.inc
Grant settings FIXME: This is nearly the same code as buildCaseTab. More utilities and less boilerplate needed.

... See full list

File

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

Code

function wf_crm_apivalues($entity, $operation, $params = [], $value = NULL) {
  if (is_numeric($params)) {
    $params = [
      'id' => $params,
    ];
  }
  $params += [
    'options' => [],
  ];

  // Work around the api's default limit of 25
  $params['options'] += [
    'limit' => 0,
  ];

  // If we only care about one field value
  if ($value && $operation == 'get') {
    $params += [
      'return' => $value,
    ];
  }
  $ret = wf_crm_aval(wf_civicrm_api($entity, $operation, $params), 'values', []);
  if ($value) {
    foreach ($ret as &$values) {
      $values = wf_crm_aval($values, $value);
    }
  }
  return $ret;
}