You are here

function sf_entity_import_field_default in Salesforce Suite 7

Same name and namespace in other branches
  1. 7.2 sf_entity/sf_entity.module \sf_entity_import_field_default()
1 string reference to 'sf_entity_import_field_default'
sf_entity_fieldmap_objects in sf_entity/sf_entity.module
Implements hook_fieldmap_objects_alter().

File

sf_entity/sf_entity.module, line 349
Integrates fieldable entities with the Salesforce API.

Code

function sf_entity_import_field_default(&$entity, $drupal_fieldname, $drupal_field_definition, $sf_data, $sf_fieldname, $sf_field_definition) {
  $data = array();

  // Convert data based on what SF type we're importing.
  switch ($sf_field_definition['salesforce']['type']) {
    case 'multipicklist':

      // SF sends multiple values as a semicolon-delimited string.
      if ($drupal_field_definition['multiple']) {
        $sf_data = explode(';', $sf_data->{$sf_fieldname});
        foreach ($sf_data as $row) {
          $data[] = array(
            'value' => $row,
          );
        }
      }
      else {
        $data[0]['value'] = $sf_data->{$sf_fieldname};
      }
      break;
    default:

      // Unless handled above in this switch, we don't yet handle fields with multiple values.
      $data[0]['value'] = $sf_data->{$sf_fieldname};
      break;
  }
  $entity->{$drupal_fieldname} = $data;
}