taxonomy_vocabulary_save
- Versions
- 7
taxonomy_vocabulary_save($vocabulary)
Save a vocabulary given a vocabulary object.
Code
modules/taxonomy/taxonomy.module, line 331
<?php
function taxonomy_vocabulary_save($vocabulary) {
if (!empty($vocabulary->name)) {
// Prevent leading and trailing spaces in vocabulary names.
$vocabulary->name = trim($vocabulary->name);
}
if (!isset($vocabulary->module)) {
$vocabulary->module = 'taxonomy';
}
if (!empty($vocabulary->vid) && !empty($vocabulary->name)) {
$status = drupal_write_record('taxonomy_vocabulary', $vocabulary, 'vid');
module_invoke_all('taxonomy_vocabulary_update', $vocabulary);
}
elseif (empty($vocabulary->vid)) {
$status = drupal_write_record('taxonomy_vocabulary', $vocabulary);
field_attach_create_bundle('taxonomy_term', $vocabulary->machine_name);
taxonomy_vocabulary_create_field($vocabulary);
module_invoke_all('taxonomy_vocabulary_insert', $vocabulary);
}
cache_clear_all();
entity_get_controller('taxonomy_vocabulary')->resetCache();
return $status;
}
?>Login or register to post comments 