You are here

function taxonomy_uuid_node_features_rebuild_alter in UUID Features Integration 6

Implementation of hook_uuid_node_features_rebuild_alter(). Build a taxonomy array suitable for node_save() from the uuid_term array.

File

includes/modules/taxonomy.inc, line 44
uuid_node hooks on behalf of the taxonomy module.

Code

function taxonomy_uuid_node_features_rebuild_alter(&$node, $module) {
  if (!empty($node->uuid_term)) {
    $node->taxonomy = array();
    foreach ($node->uuid_term as $uuid) {
      $tid = uuid_get_serial_id('term_data', 'tid', $uuid);
      if (empty($tid)) {

        // If no tid was found, then the term doesn't exist, and most likely
        // the uuid_term rebuild needs to run first.
        // TODO: figure out how to weight feature components.
        uuid_term_features_rebuild($module);

        // Now try again.
        $tid = uuid_get_serial_id('term_data', 'tid', $uuid);
        if (empty($tid)) {
          watchdog('uuid_features', 'The term specified by %uuid could not be found.', array(
            '%uuid' => $uuid,
          ));
          continue;
        }
      }
      $node->taxonomy[] = $tid;
    }
  }
}