Taxonomy vocabularies are in the CMI as of Drupal 8, but I want to also keep the Taxonomy terms in code. I am programmatically creating terms in a custom module.
function taxonomy_vocab_install() {
foreach (taxonomy_term_info() as $term_info) {
$term = Term::create(array(
'parent' => array(),
'name' => $term_info['name'],
'description' => [
'value' => $term_info['description'],
'format' => 'full_html',
],
'vid' => 'department',
));
$term->save();
};
};
Now, I want to delete the terms on uninstall, but taxonomy_term_delete is depreciated. Any help on how to programmatically delete the created taxonomy terms in D8 when the module is uninstalled would be greatly appreciated.
function taxonomy_department_uninstall() {
// ??
};