You are here

function number_feeds_set_target in Feeds 7.2

Same name and namespace in other branches
  1. 8.2 mappers/number.inc \number_feeds_set_target()

Callback for mapping number fields.

2 string references to 'number_feeds_set_target'
list_feeds_processor_targets in mappers/list.inc
Implements hook_feeds_processor_targets().
number_feeds_processor_targets in mappers/number.inc
Implements hook_feeds_processor_targets().

File

mappers/number.inc, line 37
On behalf implementation of Feeds mapping API for number.module.

Code

function number_feeds_set_target(FeedsSource $source, $entity, $target, array $values, array $mapping) {
  $language = $mapping['language'];

  // Iterate over all values.
  $field = isset($entity->{$target}) ? $entity->{$target} : array(
    $language => array(),
  );
  foreach ($values as $value) {
    if (is_object($value) && $value instanceof FeedsElement) {
      $value = $value
        ->getValue();
    }
    if (is_numeric($value)) {
      $field[$language][] = array(
        'value' => $value,
      );
    }
  }
  $entity->{$target} = $field;
}