You are here

public function MigratePhysicalDimensionsFieldHandler::prepare in Physical Fields 7

File

includes/migrate/dimensions.inc, line 50

Class

MigratePhysicalDimensionsFieldHandler
Class MigratePhysicalDimensionsFieldHandler

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();
  }
  if (empty($values)) {
    $values = array(
      0 => '',
    );
  }
  $language = $this
    ->getFieldLanguage($entity, $field_info, $arguments);
  foreach ($values as $delta => $value) {
    $item = array();
    foreach (array_keys(self::fields('', '')) as $subfield) {
      if (isset($arguments[$subfield])) {
        if (!is_array($arguments[$subfield])) {
          $item[$subfield] = $arguments[$subfield];
        }
        else {
          if (isset($arguments[$subfield][$delta])) {
            $item[$subfield] = $arguments[$subfield][$delta];
          }
        }
      }
    }
    $return[$language][$delta] = $item;
  }
  return isset($return) ? $return : NULL;
}