You are here

function taxonomy_entity_uuid_presave in Universally Unique IDentifier 7

Implements hook_entity_uuid_presave().

Related topics

File

./uuid.core.inc, line 249
Implementation of UUID hooks for all core modules.

Code

function taxonomy_entity_uuid_presave(&$entity, $entity_type) {
  if ($entity_type == 'taxonomy_term') {
    if (isset($entity->parent)) {
      if (!is_array($entity->parent)) {
        $entity->parent = array(
          $entity->parent,
        );
      }
      $ids = entity_get_id_by_uuid('taxonomy_term', $entity->parent);
      $entity->parent = array_values($ids);
    }
    $vocabulary = taxonomy_vocabulary_machine_name_load($entity->vocabulary_machine_name);
    $entity->vid = $vocabulary->vid;
  }
}