You are here

function email_feeds_set_target in Email Field 7

Callback function for mapping email field.

This function is invoked via hook_feeds_processor_targets_alter(). Here is where the actual mapping happens.

Parameters

$target: the name of the field the user has decided to map to.

$value: the value of the feed item element the user has picked as a source.

1 string reference to 'email_feeds_set_target'
email_feeds_processor_targets_alter in ./email.feeds.inc
Implements hook_feeds_processor_targets_alter().

File

./email.feeds.inc, line 36
Integration with the Feeds module.

Code

function email_feeds_set_target($source, $entity, $target, $value) {
  $value = is_array($value) ? $value : array(
    $value,
  );
  $info = field_info_field($target);

  // Iterate over all values.
  $i = 0;
  $field = isset($entity->{$target}) ? $entity->{$target} : array();
  foreach ($value as $v) {
    if (!is_array($v) && !is_object($v)) {
      $field[LANGUAGE_NONE][$i]['email'] = $v;
    }
    if ($info['cardinality'] == 1) {
      break;
    }
    $i++;
  }
  $entity->{$target} = $field;
}