function range_feeds_set_target in Range 7
Callback for mapping numeric ranges.
Ensure that $value is a numeric to avoid database errors.
1 string reference to 'range_feeds_set_target'
- range_feeds_processor_targets_alter in ./
range.feeds.inc - Implements hook_feeds_processor_targets_alter().
File
- ./
range.feeds.inc, line 44 - Implementation of Feeds mapping API.
Code
function range_feeds_set_target($source, $entity, $target, $value) {
// Do not perform the regular empty() check here. 0 is a valid value. That's
// really just a performance thing anyway.
if (!is_array($value)) {
$value = array(
$value,
);
}
// Iterate over all values.
list($field_name, $column) = explode(':', $target);
$info = field_info_field($field_name);
$field = isset($entity->{$field_name}) ? $entity->{$field_name} : array(
LANGUAGE_NONE => array(),
);
$delta = 0;
foreach ($value as $v) {
if ($info['cardinality'] == $delta) {
break;
}
if (is_object($v) && $v instanceof FeedsElement) {
$v = $v
->getValue();
}
if (is_numeric($v)) {
$field[LANGUAGE_NONE][$delta][$column] = $v;
$delta++;
}
}
$entity->{$field_name} = $field;
}