You are here

public function CivicrmEntityType::fetchFields in CRM Core 7

Fetch field from CiviCRM.

2 calls to CivicrmEntityType::fetchFields()
CivicrmActivityEntityType::getEntityFields in modules/crm_core_data_import/plugins/source_plugins/civicrm/CivicrmActivityEntityType.inc
Returns available fields.
CivicrmContactEntityType::getEntityFields in modules/crm_core_data_import/plugins/source_plugins/civicrm/CivicrmContactEntityType.inc
Returns available fields.

File

modules/crm_core_data_import/plugins/source_plugins/civicrm/CivicrmEntityType.inc, line 35
Default CiviCRM source plugin.

Class

CivicrmEntityType
@file Default CiviCRM source plugin.

Code

public function fetchFields($entity_type_name, $entity_type_value, $entity_type_field = FALSE) {
  $fields = array();
  $options = array();
  if (!empty($entity_type_field)) {
    $options[$entity_type_field] = $entity_type_value;
  }
  $entity_name = $this
    ->getEntityName();
  $entity_label = $entity_name . ':' . $entity_type_name;

  // Both this activity types returns not full field list if requested by
  // 'Activity' entity name.
  // @todo fix for the additional fields in contributions and participants.
  if ($entity_type_name == 'Event Registration') {
    $entity_name = 'participant';
  }
  if ($entity_type_name == 'Contribution') {
    $entity_name = 'contribution';
  }
  $entity = crm_core_data_import_civicrm_api($entity_name, 'getfields', $options);
  if (!empty($entity)) {
    foreach ($entity as $name => $value) {
      if (!empty($value['name'])) {
        $key = $value['name'];
      }
      else {
        $key = $name;
      }
      $field_label = $key;
      if (!empty($value['label'])) {
        $field_label .= ' - ' . $value['label'];
      }
      $fields[$entity_label][$entity_label . ':' . $key] = $field_label;
    }
  }
  return $fields;
}