You are here

function hook_content_migrate_data_record_alter in Content Construction Kit (CCK) 7.3

Implement this hook to alter individual data records as they are migrated.

This hook is called after the old data record has been read from the database and before it is inserted into the corresponding D7 field. The data column names are renamed in a one-to-one mapping by the order they appear in the database. This is often the desired behavior, but in some cases an implementation of this hook may need to move data between columns.

Parameters

$record: The data record, as read by _content_migrate_batch_process_migrate_data(). If the ordering of the D6 and D7 field columns remain the same, no action is required. If the columns were re-ordered or the data format was changed, $record should be modified to fit the new field definition.

$field:

2 functions implement hook_content_migrate_data_record_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

file_content_migrate_data_record_alter in modules/content_migrate/modules/content_migrate.file.inc
Implements hook_content_migrate_data_record_alter().
text_content_migrate_data_record_alter in modules/content_migrate/modules/content_migrate.text.inc
Implements hook_content_migrate_data_record_alter().
1 invocation of hook_content_migrate_data_record_alter()
_content_migrate_batch_process_migrate_data in modules/content_migrate/includes/content_migrate.admin.inc
Batch operation callback to migrate data. Copy old table data to new field table.

File

modules/content_migrate/content_migrate.api.php, line 67
Documentation for content migrate API.

Code

function hook_content_migrate_data_record_alter(&$record, $field, $instance) {
  switch ($field['type']) {
    case 'file':

      // Map D6 filefield field columns to D7 file field columns. Note the data
      // which was previously in the 'data' column is read into the
      // 'description' column since the data column no longer exists.
      if (!empty($record[$field['field_name'] . '_description']) && ($data = unserialize($record[$field['field_name'] . '_description']))) {
        $record[$field['field_name'] . '_description'] = $data['description'];
      }
      else {
        unset($record[$field['field_name'] . '_description']);
      }
      break;
  }
}