function icon_field_feeds_set_target in Icon API 7
Same name and namespace in other branches
- 8 modules/icon_field/icon_field.feeds.inc \icon_field_feeds_set_target()
Callback function to set value of a icon field.
1 string reference to 'icon_field_feeds_set_target'
- icon_field_feeds_processor_targets_alter in modules/
icon_field/ icon_field.feeds.inc - Implements hook_feeds_processor_targets_alter().
File
- modules/
icon_field/ icon_field.feeds.inc, line 56 - icon_field.feeds.inc Feeds mapping implementation for the Icon Field module.
Code
function icon_field_feeds_set_target($source, $entity, $target, $value, $mapping) {
// Don't do anything if we weren't given any data.
if (empty($value)) {
return;
}
// Assume that the passed in value could really be any number of values.
if (is_array($value)) {
$values = $value;
}
else {
$values = array(
$value,
);
}
// Add in default values.
$mapping += array(
'term_search' => 'lullacons_pack1',
);
$iterator = 0;
$field = isset($entity->{$target}) ? $entity->{$target} : array();
$language = isset($mapping['language']) ? $mapping['language'] : LANGUAGE_NONE;
foreach ($values as $value) {
$field[$language][$iterator]['bundle'] = $mapping['icon_bundle'];
$field[$language][$iterator]['icon'] = $value;
$iterator++;
}
// Add the field to the entity definition.
$entity->{$target} = $field;
}