You are here

protected function MigrateAddressFieldHandler::prepareArguments in Address Field 7

Builds an array with additional data for the current $delta.

Parameters

array $arguments:

array $field_info:

$delta:

Return value

array

1 call to MigrateAddressFieldHandler::prepareArguments()
MigrateAddressFieldHandler::prepare in ./addressfield.migrate.inc
Implements MigrateFieldHandler::prepare().

File

./addressfield.migrate.inc, line 142
Base integration with the Migrate API class.

Class

MigrateAddressFieldHandler
Primary value passed to this field must be the two letter ISO country code of the address.

Code

protected function prepareArguments(array $arguments, array $field_info, $delta) {
  $result = array();
  $data = array();
  foreach ($arguments as $column_key => $column_value) {
    $value = NULL;
    if (is_array($arguments[$column_key])) {
      if (!empty($arguments[$column_key][$delta])) {
        $value = $arguments[$column_key][$delta];
      }
    }
    else {
      $value = $arguments[$column_key];
    }
    if ($value) {
      if (isset($field_info['columns'][$column_key])) {

        // Store the data in a separate column.
        $result[$column_key] = $value;
      }
      else {

        // Add the data to the 'data' column.
        $data[$column_key] = $value;
      }
    }
  }

  // Store all the other data as a serialized array in the data field.
  if (!empty($data)) {
    $result['data'] = serialize($data);
  }
  return $result;
}