You are here

function field_property_get_all_entity_revision_ids in Field property 7

Return an array of all the revision IDs of a given entity.

1 call to field_property_get_all_entity_revision_ids()
field_property_field_attach_update in ./field_property.module
Implements hook_field_attach_update().

File

./field_property.module, line 82
Allows fields to be properties and have the same value across all revisions.

Code

function field_property_get_all_entity_revision_ids($entity_type, $entity, $exclude_current_revision_id = FALSE) {
  $info = entity_get_info($entity_type);
  if (empty($info['entity keys']['id']) || empty($info['entity keys']['revision']) || empty($info['revision table'])) {
    return array();
  }
  list($entity_id, $revision_id) = entity_extract_ids($entity_type, $entity);
  $id_key = $info['entity keys']['id'];
  $revision_key = $info['entity keys']['revision'];
  $query = db_select($info['revision table'], 'revision');
  $query
    ->addField('revision', $revision_key);
  $query
    ->condition('revision.' . $id_key, $entity_id);
  if ($exclude_current_revision_id) {
    $query
      ->condition('revision.' . $revision_key, $revision_id, '<>');
  }
  return $query
    ->execute()
    ->fetchCol();
}