function uuid_term_features_rebuild in UUID Features Integration 6
Same name and namespace in other branches
- 7 includes/uuid_term.features.inc \uuid_term_features_rebuild()
Implementation of hook_features_rebuild(). Rebuilds terms based on UUID from code defaults.
2 calls to uuid_term_features_rebuild()
- taxonomy_uuid_node_features_rebuild_alter in includes/
modules/ taxonomy.inc - Implementation of hook_uuid_node_features_rebuild_alter(). Build a taxonomy array suitable for node_save() from the uuid_term array.
- uuid_term_features_revert in includes/
uuid_term.features.inc - Implementation of hook_features_revert().
File
- includes/
uuid_term.features.inc, line 121 - Features hooks for the uuid_term features component.
Code
function uuid_term_features_rebuild($module) {
$terms = module_invoke($module, 'uuid_features_default_terms');
if (!empty($terms)) {
foreach ($terms as $data) {
$existing = uuid_get_serial_id('term_data', 'tid', $data['uuid']);
if (!empty($existing)) {
$data['tid'] = $existing;
}
$vid = db_result(db_query('SELECT vid FROM {uuid_vocabulary} WHERE uuid = "%s"', $data['uuid_vocabulary']));
if ($vid) {
$data['vid'] = $vid;
if (isset($data['parent']) && is_array($data['parent'])) {
foreach ($data['parent'] as $key => $parent_uuid) {
$data['parent'][$key] = uuid_get_serial_id('term_data', 'tid', $parent_uuid);
}
}
$ret = taxonomy_save_term($data);
// TODO: remove when http://drupal.org/node/860442 is resolved.
uuid_set_uuid('term_data', 'tid', $data['tid'], $data['uuid']);
}
}
}
}