function text_feeds_set_target in Feeds 7.2
Same name and namespace in other branches
- 8.2 mappers/text.inc \text_feeds_set_target()
Callback for mapping text fields.
2 string references to 'text_feeds_set_target'
- list_feeds_processor_targets in mappers/
list.inc - Implements hook_feeds_processor_targets().
- text_feeds_processor_targets in mappers/
text.inc - Implements hook_feeds_processor_targets().
File
- mappers/
text.inc, line 51 - On behalf implementation of Feeds mapping API for text.module.
Code
function text_feeds_set_target(FeedsSource $source, $entity, $target, array $values, array $mapping) {
$language = $mapping['language'];
list($field_name, $column) = explode(':', $target . ':value');
if ($column === 'value' && isset($source->importer->processor->config['input_format'])) {
$format = $source->importer->processor->config['input_format'];
// Add in default values.
$mapping += array(
'format' => $format,
);
}
$field = isset($entity->{$field_name}) ? $entity->{$field_name} : array(
$language => array(),
);
// Iterate over all values.
$delta = 0;
foreach ($values as $value) {
if (is_object($value) && $value instanceof FeedsElement) {
$value = $value
->getValue();
}
if (is_scalar($value) && strlen($value)) {
$field[$language][$delta][$column] = (string) $value;
if (isset($mapping['format'])) {
$field[$language][$delta]['format'] = $mapping['format'];
}
}
$delta++;
}
$entity->{$field_name} = $field;
}