You are here

public static function EntityHelper::getAllRevisionIDs in Helper 7

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

Parameters

string $entity_type: The entity type of $entity.

int $entity_id: The entity ID.

Return value

array An array of revision IDs associated with entity.

File

lib/EntityHelper.php, line 323

Class

EntityHelper

Code

public static function getAllRevisionIDs($entity_type, $entity_id) {
  $info = entity_get_info($entity_type);
  if (empty($info['entity keys']['id']) || empty($info['entity keys']['revision']) || empty($info['revision table'])) {
    return array();
  }
  $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);
  return $query
    ->execute()
    ->fetchCol();
}