You are here

function voting_rules_load_entity in Voting Rules 7

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 based on supported types (currently nodes, users, and comments) and the entity API for unknown entities.

Parameters

$entity_type: The entity type.

$entity_id: The entity ID.

3 calls to voting_rules_load_entity()
voting_rules_get_property in ./voting_rules.module
Rules callback for user and entities.
voting_rules_votingapi_results in ./voting_rules.module
Implements hook_votingapi_results().
_voting_rules_votingapi_op in ./voting_rules.module
Wrapper for hook_votingapi_insert() and hook_votingapi_delete().

File

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

Code

function voting_rules_load_entity($entity_type, $entity_id) {
  switch ($entity_type) {
    case 'node':
      return node_load($entity_id);
    case 'user':
      return user_load($entity_id);
    case 'comment':
      return comment_load($entity_id);
    default:
      $entity_key = voting_rules_get_entity_key($entity_type);
      $entities = entity_load($entity_type, array(
        $entity_id,
      ));
      $entity = reset($entities);
      return $entity;
  }
}