1 taxonomy.api.php hook_taxonomy_vocabulary_insert(TaxonomyVocabulary $vocabulary)

Act on taxonomy vocabularies when inserted.

Modules implementing this hook can act on the vocabulary object when saved to the database.

Parameters

TaxonomyVocabulary $vocabulary: A taxonomy vocabulary.

Related topics

File

core/modules/taxonomy/taxonomy.api.php, line 54
Hooks provided by the Taxonomy module.

Code

function hook_taxonomy_vocabulary_insert(TaxonomyVocabulary $vocabulary) {
  if ($vocabulary->machine_name == 'my_vocabulary') {
    db_insert('mytable')
      ->fields(array(
        'vocabulary' => $vocabulary->machine_name,
        'foo' => $vocabulary->foo,
      ))
      ->execute();
  }
}