function rules_action_entity_fetch

Action: Fetch data.

Related topics

1 string reference to 'rules_action_entity_fetch'
rules_entity_action_info in modules/entity.rules.inc
Implements hook_rules_action_info() on behalf of the entity module.

File

modules/entity.eval.inc, line 15

Code

function rules_action_entity_fetch($type, $id, $revision) {
    $info = entity_get_info($type);
    // Support the revision parameter, if applicable.
    if (!empty($info['entity keys']['revision']) && isset($revision)) {
        $conditions = array(
            $info['entity keys']['revision'] => $revision,
        );
    }
    $return = entity_load($type, array(
        $id,
    ), isset($conditions) ? $conditions : array());
    $entity = reset($return);
    if (!$entity) {
        throw new RulesEvaluationException('Unable to load @entity with id "@id"', array(
            '@id' => $id,
            '@entity' => $type,
        ));
    }
    return array(
        'entity_fetched' => $entity,
    );
}