I am trying to create a data description (snippet below) for the video node provided by the video.module, so I can import from xml to db and vice versa. I took the code in importexportapi_forum.inc as a starting point and just added an array to map the contents of the 'video' table (tagging it 'video_contents').
* Export works fine.
* However, when importing with no keys (nid and vid), the module fails to retrieve the reference in the vid field of video_contents (referencing revisions.vid). As a result 0 is inserted into the vid column of the video table. All other values are imported successfully.
The cause is probably in my usage of the #reference_field property when defining ['video_contents']['vid']. I'd appreciate if someone could point me in the right direction and/or clarify how #reference_field is supposed to work.
snippet from importexportapi_video.inc
function video_def() {
$defs = array();
$type = 'video';
$def = importexportapi_node_get_def($type);
$type_info = module_invoke($type, 'node_info');
$type_info = $type_info[$type];
$def['#title'] = $type_info['name'];
$def['#title'][0] = strtoupper($def['#title'][0]);
$def['#xml_plural'] = $def['#csv_plural'] = 'videos';
$def['revisions']['#csv_plural'] = 'video-revisions';
$def['type']['#db_filter'] = array(
'values' => array($type)
);
$def['video_contents'] = array(
'#type' => 'array',
'#title' => t('Video Contents'),
'#db_default_table' => 'video',
'#xml_plural' => 'video_contents',
'#xml_mapping' => 'video_content',
'#csv_plural' => 'video_contents'
);
$def['video_contents']['nid'] = array(
'#type' => 'int',
'#title' => t('Node ID'),
'#reference_entity' => $type,
'#reference_field' => array('nid'),
'#db_table' => 'video',
'#db_field_unaliased' => 'nid',
'#key_component' => TRUE
);
$def['video_contents']['vid'] = array(
'#type' => 'int',
'#title' => t('Revision ID'),
'#reference_entity' => $type,
'#reference_field' => array('revisions','vid'),
'#db_table' => 'video',
'#db_field_unaliased' => 'vid',
'#key_component' => TRUE
);
$def['video_contents']['vidfile'] = array(
'#type' => 'string',
'#title' => t('Video File'),
'#db_table' => 'video',
'#db_field_unaliased' => 'vidfile'
);
...