Skip to content

Instantly share code, notes, and snippets.

@cotto
Created September 8, 2012 07:19
Show Gist options
  • Save cotto/3672527 to your computer and use it in GitHub Desktop.
Save cotto/3672527 to your computer and use it in GitHub Desktop.
spot the bug
/**
* Implements of hook_entity_property_info_alter().
*
* This adds the UUID as an entity property for all UUID-enabled entities
* which automatically gives us token and Rules integration.
*/
function uuid_entity_property_info_alter(&$info) {
foreach (entity_get_info() as $entity_type => $info) {
if (isset($info['uuid']) && $info['uuid'] == TRUE && !empty($info['entity keys']['uuid'])) {
$info[$entity_type]['properties'][$info['entity keys']['uuid']] = array(
'label' => t('UUID'),
'type' => 'text',
'description' => t('The universally unique ID.'),
'schema field' => $info['entity keys']['uuid'],
);
if (!empty($info['entity keys']['revision uuid'])) {
$info[$entity_type]['properties'][$info['entity keys']['revision uuid']] = array(
'label' => t('Revision UUID'),
'type' => 'text',
'description' => t("The revision's universally unique ID."),
'schema field' => $info['entity keys']['revision uuid'],
);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment