function field_feeds_set_target in Feeds 7
Callback for mapping. Here is where the actual mapping happens.
When the callback is invoked, $target contains the name of the field the user has decided to map to and $value contains the value of the feed item element the user has picked as a source.
1 string reference to 'field_feeds_set_target'
- field_feeds_processor_targets_alter in mappers/
field.inc - Implements hook_feeds_processor_targets_alter().
File
- mappers/
field.inc, line 45 - On behalf implementation of Feeds mapping API for field.module.
Code
function field_feeds_set_target($entity, $target, $value) {
if (empty($value)) {
return;
}
// Handle non-multiple value fields.
if (!is_array($value)) {
$value = array(
$value,
);
}
$info = field_info_field($target);
// Iterate over all values.
$i = 0;
$field = isset($entity->{$target}) ? $entity->{$target} : array();
foreach ($value as $v) {
if (!is_array($v) && !is_object($v)) {
$field['und'][$i]['value'] = $v;
}
if ($info['cardinality'] == 1) {
break;
}
$i++;
}
$entity->{$target} = $field;
}