You are here

function entity_metadata_taxonomy_term_setter in Entity API 7

Callback for setting term properties.

See also

entity_metadata_taxonomy_entity_info_alter()

1 string reference to 'entity_metadata_taxonomy_term_setter'
entity_metadata_taxonomy_entity_property_info in modules/taxonomy.info.inc
Implements hook_entity_property_info() on top of taxonomy module.

File

modules/callbacks.inc, line 332
Provides various callbacks for the whole core module integration.

Code

function entity_metadata_taxonomy_term_setter($term, $name, $value) {
  switch ($name) {
    case 'vocabulary':

      // 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 = $vocabulary->vid;
    case 'parent':
      return $term->parent = $value;
  }
}