You are here

function book_uuid_entity_features_rebuild_complete in UUID Features Integration 7

Implements hook_uuid_entity_features_rebuild_complete().

Ensure complete book structure has been set up.

File

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

Code

function book_uuid_entity_features_rebuild_complete($entity_type, $entities, $module) {
  if ($entity_type == 'node') {

    // Reset the node cache.
    node_load(FALSE, NULL, TRUE);
    $pending = _book_uuid_node_features_pending();
    if (!empty($pending)) {

      // Sort so that parent nodes come before child nodes.
      $pending = _book_uuid_node_features_pending_sort($pending);
    }
    foreach ($pending as $uuid => $book) {
      $book_page_node = entity_load_single_by_uuid('node', $uuid);
      $parent_node = entity_load_single_by_uuid('node', $book['parent_uuid']);

      // Set up node as for add child page.
      $book_page_node->book['bid'] = $parent_node->book['bid'];
      $book_page_node->book['plid'] = $parent_node->book['mlid'];
      $book_page_node->book['menu_name'] = $parent_node->book['menu_name'];
      $book_page_node->book['weight'] = $book['weight'];
      node_save($book_page_node);
      node_load($book_page_node->nid, NULL, TRUE);
    }
  }
}