summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfago2012-10-23 17:48:43 (GMT)
committer fago2012-10-23 17:48:43 (GMT)
commit5731f741e3366889e95b5357f1f85b0acc51a9fe (patch)
tree11efd35fe00424b896487bb478074bb708f3aa50
parente7b054ffe9eca11641204ef0c69c603ff6a03394 (diff)
Allow setting the term vocabulary property by vocabulary ID or name.
-rw-r--r--modules/callbacks.inc7
1 files changed, 4 insertions, 3 deletions
diff --git a/modules/callbacks.inc b/modules/callbacks.inc
index 5203028..1288661 100644
--- a/modules/callbacks.inc
+++ b/modules/callbacks.inc
@@ -292,10 +292,11 @@ function entity_metadata_taxonomy_term_get_properties($term, array $options, $na
function entity_metadata_taxonomy_term_setter($term, $name, $value) {
switch ($name) {
case 'vocabulary':
- // Make sure to also update the taxonomy bundle key.
- $vocabulary = taxonomy_vocabulary_load($value);
+ // Make sure to update the taxonomy bundle key, so load the vocabulary.
+ // Support both, loading by name or ID.
+ $vocabulary = is_numeric($value) ? taxonomy_vocabulary_load($value) : taxonomy_vocabulary_machine_name_load($value);
$term->vocabulary_machine_name = $vocabulary->machine_name;
- return $term->vid = $value;
+ return $term->vid = $vocabulary->vid;
case 'parent':
return $term->parent = $value;
}