function uuid_term_features_get_dependencies in UUID Features Integration 7
Adds terms and its dependencies to the export.
Parents and term references are handled recursively, other references are not yet supported.
2 calls to uuid_term_features_get_dependencies()
- uuid_features_features_pipe_taxonomy_alter in ./
uuid_features.module - Implements hook_features_pipe_COMPONENT_alter().
- uuid_term_features_export in includes/
uuid_term.features.inc - Implements hook_features_export().
File
- includes/
uuid_term.features.inc, line 74 - Features hooks for the uuid_term features component.
Code
function uuid_term_features_get_dependencies(&$export, $uuid, $module_name = '') {
$map = features_get_default_map('taxonomy');
$terms = entity_uuid_load('taxonomy_term', array(
$uuid,
), array(), TRUE);
if (!isset($export['features']['uuid_term'])) {
$export['features']['uuid_term'] = array();
}
if (!isset($export['features']['taxonomy'])) {
$export['features']['taxonomy'] = array();
}
if (count($terms)) {
$term = reset($terms);
$export['features']['uuid_term'][$uuid] = $uuid;
$machine_name = $term->vocabulary_machine_name;
if (isset($map[$machine_name]) && $map[$machine_name] != $module_name) {
$export['dependencies'][$map[$machine_name]] = $map[$machine_name];
}
else {
$export['features']['taxonomy'][$machine_name] = $machine_name;
}
// Recursively add all parents and the references of the parents.
foreach (taxonomy_get_parents($term->tid) as $parent) {
if (!in_array($parent->uuid, $export['features']['uuid_term'])) {
uuid_term_features_get_dependencies($export, $parent->uuid, $module_name);
}
}
// Get term references.
$instances = field_info_instances('taxonomy_term', $machine_name);
foreach ($instances as $field_name => $instance) {
$field = field_info_field($field_name);
if ($field['type'] == 'taxonomy_term_reference') {
if (isset($term->{$field_name})) {
foreach ($term->{$field_name} as $lang => $values) {
foreach ($values as $value) {
// $value['tid'] already contains the UUID.
if (!in_array($value['tid'], $export['features']['uuid_term'])) {
uuid_term_features_get_dependencies($export, $value['tid'], $module_name);
}
}
}
}
}
}
}
}