function blockreference_feeds_set_target in Block reference 7.2
Block reference callback for mapping.
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.
Parameters
$source: A FeedsSource object.
$entity: The entity to map to.
$target: The target key on $entity to map to.
$value: The value to map. MUST be an array.
1 string reference to 'blockreference_feeds_set_target'
File
- ./
blockreference.feeds.inc, line 41
Code
function blockreference_feeds_set_target($source, $entity, $target, $value) {
// Assume that the passed in value could really be any number of values.
$values = array_filter((array) $value);
// Don't do anything if we weren't given any data.
if (!$value) {
return;
}
list($target, $match_key) = explode(':', $target, 2);
// Set the language of the field depending on the mapping.
$language = isset($match_key['language']) ? $match_key['language'] : LANGUAGE_NONE;
// Iterate over all values.
$items = array();
foreach ($values as $value) {
@(list($module, $delta) = explode(':', $value));
if ($module && $delta) {
$exists = db_query('SELECT bid FROM {block} WHERE module = ? AND delta = ?', array(
$module,
$delta,
))
->fetchField();
if ($exists) {
$items[$language][]['moddelta'] = $value;
}
}
}
$entity->{$target} = $items;
}