function matrix_content_migrate_data_record_alter in Matrix field 7.2
Same name and namespace in other branches
- 8.2 migrate.inc \matrix_content_migrate_data_record_alter()
Implementation of hook_content_migrate_data_record_alter().
The data in matrix has a one-to-many relationship from node to data This hook does the inserts rather than content_migrate which assumes a one-to-one relationship
File
- ./
migrate.inc, line 27 - Hook implementations to assist with the migration from Drupal 6 to 7
Code
function matrix_content_migrate_data_record_alter(&$record, $field) {
switch ($field['type']) {
case 'matrix_text':
case 'matrix_custom':
$new_table = content_migrate_new_table($field);
$new_revision_table = content_migrate_new_revision($field);
$result = db_query("SELECT * FROM {node_field_matrix_data} WHERE nid = :nid AND vid = :vid AND field_name = :field_name", array(
':nid' => $record['entity_id'],
':vid' => $record['revision_id'],
':field_name' => $field['field_name'],
));
foreach ($result as $row) {
$record[$field['field_name'] . '_row'] = $row->row + 1;
$record[$field['field_name'] . '_col'] = $row->col + 1;
$record[$field['field_name'] . '_value'] = $row->value;
if (!empty($record)) {
if ($record['revision_id'] == $row->vid) {
drupal_write_record($new_table, $record);
}
drupal_write_record($new_revision_table, $record);
}
$record['delta']++;
}
$record = array();
//prevent content_migrate from processing anything
break;
}
}