function taxonomy_taxonomy_vocabulary_update

Implements hook_taxonomy_vocabulary_update().

File

modules/taxonomy/taxonomy.module, line 531

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);
                }
            }
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.