You are here

function link_feeds_set_target in Feeds 7.2

Same name and namespace in other branches
  1. 8.2 mappers/link.inc \link_feeds_set_target()
  2. 6 mappers/link.inc \link_feeds_set_target()
  3. 7 mappers/link.inc \link_feeds_set_target()

Callback for mapping link fields.

1 string reference to 'link_feeds_set_target'
link_feeds_processor_targets in mappers/link.inc
Implements hook_feeds_processor_targets().

File

mappers/link.inc, line 42
On behalf implementation of Feeds mapping API for link.module.

Code

function link_feeds_set_target(FeedsSource $source, $entity, $target, array $values, array $mapping) {
  $language = $mapping['language'];
  list($field_name, $column) = explode(':', $target);
  $field = isset($entity->{$field_name}) ? $entity->{$field_name} : array(
    $language => array(),
  );
  $delta = 0;
  foreach ($values as $value) {
    if (is_object($value) && $value instanceof FeedsElement) {
      $value = $value
        ->getValue();
    }
    if (is_scalar($value)) {
      $field[$language][$delta][$column] = (string) $value;
    }
    $delta++;
  }
  $entity->{$field_name} = $field;
}