function rules_tokens

Implements hook_tokens().

File

./rules.module, line 1751

Code

function rules_tokens($type, $tokens, $data, $options = array()) {
    // Handle replacements of primitive variable types.
    if (substr($type, 0, 6) == 'rules_' && !empty($data[$type])) {
        // Leverage entity tokens token processor by passing on as struct.
        $info['property info']['value'] = array(
            'type' => substr($type, 6),
            'label' => '',
        );
        // Entity tokens uses metadata wrappers as values for 'struct' types.
        $wrapper = entity_metadata_wrapper('struct', array(
            'value' => $data[$type],
        ), $info);
        return entity_token_tokens('struct', $tokens, array(
            'struct' => $wrapper,
        ), $options);
    }
}