You are here

function book_uuid_node_features_export_render_alter in UUID Features Integration 7

Implements hook_uuid_node_features_export_render_alter().

For root book pages - set bid to new. For child pages set a parent_uuid to use on rebuild. Clear all other book properties.

File

includes/modules/book.inc, line 32
uuid_node hooks on behalf of the book module.

Code

function book_uuid_node_features_export_render_alter(&$export, $node, $module) {
  if (isset($node->book) && isset($node->book['bid']) && isset($node->book['nid'])) {
    $node_book_export = array();
    if ($node->book['bid'] == $node->book['nid']) {
      $node_book_export['bid'] = 'new';
      $node_book_export['parent_depth_limit'] = 1;
    }
    else {
      $book_uuid = current(entity_get_uuid_by_id('node', array(
        $node->book['bid'],
      )));
      $node_book_export['bid'] = $book_uuid;
    }

    // If a parent is defined ensure we export the parent uuid.
    if (isset($node->book['plid']) && ($parent_menu_link = book_link_load($node->book['plid']))) {
      $parent_uuid = current(entity_get_uuid_by_id('node', array(
        $parent_menu_link['nid'],
      )));
      if (!empty($parent_uuid)) {
        $node_book_export['parent_uuid'] = $parent_uuid;
        $node_book_export['weight'] = $node->book['weight'];
      }
    }
    $export->book = $node_book_export;
  }
}