You are here

function mailchimp_signup_set_target in Mailchimp 7.3

Same name and namespace in other branches
  1. 7.5 modules/mailchimp_signup/mailchimp_signup.module \mailchimp_signup_set_target()
  2. 7.4 modules/mailchimp_signup/mailchimp_signup.module \mailchimp_signup_set_target()

Mapping callback.

1 string reference to 'mailchimp_signup_set_target'
mailchimp_signup_feeds_processor_targets_alter in modules/mailchimp_signup/mailchimp_signup.module
Implements hook_feeds_node_processor_targets_alter().

File

modules/mailchimp_signup/mailchimp_signup.module, line 456
Mailchimp Signup module. Allows creation of signup forms integrated with Mailchimp.

Code

function mailchimp_signup_set_target($source, $entity, $target, $value, $mapping) {
  list($field_name, $option) = explode(':', $target . ':value');
  $field = isset($entity->{$field_name}) ? $entity->{$field_name} : array(
    'und' => array(),
  );
  $delta = 0;
  if (is_array($value)) {
    foreach ($value as $each_value) {
      if (is_object($each_value) && $each_value instanceof FeedsElement) {
        $each_value = $value
          ->getValue();
        $field['und'][$delta] = array(
          $option => $each_value,
        );
      }
      $delta++;
    }
  }
  else {
    $field['und'][$delta] = array(
      $option => $value,
    );
  }
  $entity->{$field_name} = $field;
}