You are here

public function MigratePhysicalWeightFieldHandler::prepare in Physical Fields 7

File

includes/migrate/weight.inc, line 42

Class

MigratePhysicalWeightFieldHandler
Class MigratePhysicalWeightFieldHandler

Code

public function prepare($entity, array $field_info, array $instance, array $values) {
  if (isset($values['arguments'])) {
    $arguments = $values['arguments'];
    unset($values['arguments']);
  }
  else {
    $arguments = array();
  }
  $language = $this
    ->getFieldLanguage($entity, $field_info, $arguments);
  foreach ($values as $delta => $value) {
    $item = array();
    if (isset($arguments['unit'])) {
      if (!is_array($arguments['unit'])) {
        $item['unit'] = $arguments['unit'];
      }
      else {
        if (isset($arguments['unit'][$delta])) {
          $item['unit'] = $arguments['unit'][$delta];
        }
      }
    }
    $item['weight'] = $value;
    $return[$language][$delta] = $item;
  }
  return isset($return) ? $return : NULL;
}