You are here

asset_uuid.module in Asset 7

Implement UUID/Entity hooks for integrating with deploy and other modules.

File

modules/asset_uuid/asset_uuid.module
View source
<?php

/**
 * @file
 * Implement UUID/Entity hooks for integrating with deploy and other modules.
 */

/**
 * Implements hook_entity_info_alter().
 */
function asset_uuid_entity_info_alter(&$entity_info) {

  // Set the properties bellow for asset entity so UUIDs get created on sync.
  $entity_info['asset']['uuid'] = TRUE;
  $entity_info['asset']['entity keys']['uuid'] = 'uuid';
}

/**
 * Implements hook_entity_uuid_load().
 */
function asset_uuid_entity_uuid_load(&$entities, $entity_type) {
  if ($entity_type == 'asset') {
    entity_property_id_to_uuid($entities, 'asset', 'aid');
  }
}

/**
 * Implements hook_entity_uuid_presave().
 */
function asset_uuid_entity_uuid_presave(&$entity, $entity_type) {
  if ($entity_type == 'asset') {
    entity_property_uuid_to_id($entity, 'asset', 'aid');
  }
}