You are here

function isbn_feeds_set_target in ISBN Field 7

Callback to set target value.

1 string reference to 'isbn_feeds_set_target'
isbn_feeds_processor_targets in ./isbn.feeds.inc
Implements hook_feeds_processor_targets().

File

./isbn.feeds.inc, line 32
Provides integration with Feeds module (http://drupal.org/project/feeds).

Code

function isbn_feeds_set_target(FeedsSource $source, $entity, $target, array $values, array $mapping) {
  $language = $mapping['language'];
  $field = isset($entity->{$target}) ? $entity->{$target} : array(
    $language => array(),
  );

  // Iterate over all values.
  foreach ($values as $value) {
    if (is_object($value) && $value instanceof FeedsElement) {
      $value = $value
        ->getValue();
    }
    $field[$language][] = array(
      'isbn' => preg_replace('/([^xX0-9]*)/', "", $value),
    );
  }
  $entity->{$target} = $field;
}