As part of my_module_install() I want to create and populate a vocabulary programmatically. To not duplicate any code I want to use the taxonomy_save_vocabulary(&$edit) function:

 $vocabulary['name'] = 'A new vocabulary';
 $vocabulary['description'] = 'I was created by my_module_install()';
 $vocabulary['help'] = '';
 $vocabulary['multiple'] = 0;
 $vocabulary['required'] = 1;
 $vocabulary['hierarchy'] = 1;
 $vocabulary['relations'] = 0;
 $vocabulary['tags'] = 0;
 $vocabulary['weight'] = 0;
 
// module_invoke('taxonomy', 'save_vocabulary', $vocabulary);

taxonomy_save_vocabulary($vocabulary);
 
 drupal_set_message('A new vocabulary: ' . $vocabulary['vid']); 

First I tried to use module_invoke, but unfortunately, it somehow mess up the call by reference and I get no $vocabulary['vid']. Calling taxonomy_save_vocabulary($vocabulary) will give me the new vid.

This might not be a huge problem, but I'm curious and hope someone can help me understand why I cannot use module_invoke.

Comments

knugar’s picture