function sf_entity_export_field_default in Salesforce Suite 7.2
Same name and namespace in other branches
- 7 sf_entity/sf_entity.module \sf_entity_export_field_default()
1 string reference to 'sf_entity_export_field_default'
- sf_entity_fieldmap_objects in sf_entity/
sf_entity.module
File
- sf_entity/
sf_entity.module, line 1263 - Integrates fieldable entities with the Salesforce API.
Code
function sf_entity_export_field_default($entity, $fieldkey, $drupal_field_definition, $sf_field_definition) {
// Get the language.
$lang = _sf_entity_get_language($entity);
// Get the data array for the field.
list($fieldname, $column) = explode(':', $fieldkey, 2);
if (empty($column)) {
$column = 'value';
}
$field = $entity->{$fieldname};
if (isset($field[$lang])) {
$data = $field[$lang];
}
elseif (!empty($entity->{$fieldname}) && is_array($entity->{$fieldname})) {
$data = current($entity->{$fieldname});
}
else {
// Uncomment the following line if debugging is necessary of why the field could not be found at all.
// sf_dpm(func_get_args(), FALSE);
return;
}
switch ($sf_field_definition['salesforce']['type']) {
case 'multipicklist':
// SF wants a semicolon-delimited string for multipicklist values
$values = array();
foreach ($data as $row) {
$values[] = $row[$column];
}
$result = implode(';', $values);
break;
default:
// Unless handled above, use only the first value.
if (isset($data[0][$column])) {
$result = $data[0][$column];
}
else {
$result = '';
}
break;
}
return $result;
}