You are here

function node_entity_uuid_presave in Universally Unique IDentifier 7

Implements hook_entity_uuid_presave().

Related topics

File

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

Code

function node_entity_uuid_presave(&$entity, $entity_type) {
  if ($entity_type == 'node') {
    entity_property_uuid_to_id($entity, 'user', array(
      'uid',
      'revision_uid',
    ));
    entity_property_uuid_to_id($entity, 'node', 'tnid');

    // A node always must have an author.
    if (empty($entity->uid)) {
      global $user;
      $entity->uid = $user->uid;
    }
  }
}