function deploy_is_latest_revision in Deploy - Content Staging 7.3
Checks if the entity is the latest revision.
Parameters
string $entity_type: The machine name of the entity type.
object $entity: The entity object to use for the look up.
Return value
bool Is the supplied entity the latest revision.
2 calls to deploy_is_latest_revision()
- deploy_views_handler_revision_class_field::render in includes/
views/ handler_revision_class_field.inc - Render the field.
- deploy_views_handler_revision_status_field::render in includes/
views/ handler_revision_status_field.inc - Render the field.
File
- ./
deploy.module, line 681 - Deploy module functions.
Code
function deploy_is_latest_revision($entity_type, $entity) {
$entity_info =& drupal_static(__FUNCTION__);
if (empty($entity_info[$entity_type])) {
$entity_info[$entity_type] = entity_get_info($entity_type);
}
$info = $entity_info[$entity_type];
// If the entity doesn't support revisions this must be considered to be the latest revision.
if (empty($info['entity keys']['revision'])) {
return TRUE;
}
$query = new EntityFieldQuery();
$result = $query
->entityCondition('entity_type', $entity_type)
->entityCondition('entity_id', $entity->{$info['entity keys']['id']})
->entityCondition('revision_id', $entity->{$info['entity keys']['revision']}, '>')
->execute();
return empty($result[$entity_type]);
}