function uuid_node_features_export_render in UUID Features Integration 7
Same name and namespace in other branches
- 6 includes/uuid_node.features.inc \uuid_node_features_export_render()
Implements hook_features_export_render().
File
- includes/
uuid_node.features.inc, line 77 - Features hooks for the uuid_node features component.
Code
function uuid_node_features_export_render($module, $data) {
$translatables = $code = $files = $return = array();
$code[] = ' $nodes = array();';
$code[] = '';
$nids = entity_get_id_by_uuid('node', $data);
// Always sort by the uuid to ensure the order is maintained.
ksort($nids);
foreach ($nids as $uuid => $nid) {
// Only export the node if it exists.
if ($nid === FALSE) {
continue;
}
// Attempt to load the node, using a fresh cache.
$node = node_load($nid, NULL, TRUE);
if (empty($node)) {
continue;
}
// If pathauto is set to 0, don't override it.
$uri = entity_uri('node', $node);
$path = drupal_get_path_alias($uri['path']);
if ($uri['path'] != $path) {
// Add path and pathauto settings.
if (!property_exists($node, 'path')) {
$node->path = array();
}
if (module_exists('pathauto')) {
// If we're not using pathauto, ensure it is disabled.
if (!isset($node->path['pathauto']) || $node->path['pathauto'] == 0) {
$node->path['pathauto'] = FALSE;
$node->path['alias'] = $path;
}
else {
$node->path['pathauto'] = TRUE;
}
}
else {
$node->path['alias'] = $path;
}
}
// Clone entity to avoid changes by reference.
$export = clone $node;
// Use date instead of created, in the same format used by
// node_object_prepare().
$export->date = format_date($export->created, 'custom', 'Y-m-d H:i:s O');
$files = uuid_features_file_field_export($export, 'node');
$entity_type = 'node';
drupal_alter('uuid_entity_features_export_render', $entity_type, $export, $node, $module);
drupal_alter('uuid_node_features_export_render', $export, $node, $module);
// Don't cause conflicts with nid/vid/revision_timestamp/changed fields.
unset($export->revision_uid);
unset($export->revision_timestamp);
unset($export->nid);
unset($export->vid);
unset($export->vuuid);
unset($export->changed);
unset($export->last_comment_timestamp);
unset($export->last_comment_id);
unset($export->last_comment_name);
unset($export->last_comment_uid);
unset($export->cid);
$code[] = ' $nodes[] = ' . features_var_export($export) . ';';
// Add packaged files, if any.
if (!empty($files)) {
foreach ($files as $filename => $src_path) {
$return[$filename] = $src_path;
}
}
}
if (!empty($translatables)) {
$code[] = features_translatables_export($translatables, ' ');
}
$code[] = ' return $nodes;';
$code = implode("\n", $code);
$return['uuid_features_default_content'] = $code;
return $return;
}