function cck_phone_feeds_set_target in Phone Number 7
Callback for feed mapping.
1 string reference to 'cck_phone_feeds_set_target'
File
- ./
cck_phone.feeds.inc, line 36 - Implements Feeds mapping API
Code
function cck_phone_feeds_set_target($source, $entity, $target, $value) {
if (empty($value)) {
return;
}
// Handle non-multiple value fields.
if (!is_array($value)) {
$value = array(
$value,
);
}
// Iterate over all values.
$i = 0;
$info = field_info_field($target);
list($field_name, $sub_field) = explode(':', $target);
// We will call this multiple times, preserve existing values.
$field = empty($entity->{$field_name}) ? array() : $entity->{$field_name};
foreach ($value as $v) {
if ($sub_field == 'country_codes') {
$v = strtolower($v);
}
if (!is_array($v) && !is_object($v)) {
$field['und'][$i][$sub_field] = $v;
}
if ($info['cardinality'] == 1) {
break;
}
$i++;
}
$entity->{$field_name} = $field;
}