function taxonomy_taxonomy_vocabulary_update in Drupal 7
Implements hook_taxonomy_vocabulary_update().
File
- modules/
taxonomy/ taxonomy.module, line 531 - Enables the organization of content into categories.
Code
function taxonomy_taxonomy_vocabulary_update($vocabulary) {
// Reflect machine name changes in the definitions of existing 'taxonomy'
// fields.
if (!empty($vocabulary->old_machine_name) && $vocabulary->old_machine_name != $vocabulary->machine_name) {
$fields = field_read_fields();
foreach ($fields as $field_name => $field) {
$update = FALSE;
if ($field['type'] == 'taxonomy_term_reference') {
foreach ($field['settings']['allowed_values'] as $key => &$value) {
if ($value['vocabulary'] == $vocabulary->old_machine_name) {
$value['vocabulary'] = $vocabulary->machine_name;
$update = TRUE;
}
}
if ($update) {
field_update_field($field);
}
}
}
}
}