You are here

function voting_rules_get_entity_key in Voting Rules 7

Helper function to get the primary key used by an entity.

Return value

An entity key.

3 calls to voting_rules_get_entity_key()
voting_rules_get_votes in ./voting_rules.module
Rules callback to get votes on an entity.
voting_rules_get_vote_results in ./voting_rules.module
Rules callback to get vote results on an entity.
voting_rules_load_entity in ./voting_rules.module
Helper function that loads content of the specified type. Since Voting API is built to support client defined content types, while Rules requires content types to be pre-defined, we use this helper function to encapsulate the loading of new content…

File

./voting_rules.module, line 115
Voting Rules module.

Code

function voting_rules_get_entity_key($entity_type) {
  switch ($entity_type) {
    case 'node':
      return 'nid';
    case 'user':
      return 'uid';
    case 'comment':
      return 'cid';
    default:
      $entity_info = entity_get_info($entity_type);
      return $entity_info['entity keys']['id'];
  }
}