-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpinapi_rules.module
More file actions
40 lines (35 loc) · 837 Bytes
/
pinapi_rules.module
File metadata and controls
40 lines (35 loc) · 837 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
/**
* @file
* Provides integration of Pin API with rules.
*/
/**
* Implements hook_pinapi_txn().
*/
function pinapi_rules_pinapi_txn($op, &$txn) {
// Map hook operations to rules events.
$event = NULL;
switch ( $op ) {
case 'create':
$event = 'pinapi_event_txn_create';
break;
case 'pre redeem':
$event = 'pinapi_event_txn_pre_redeem';
break;
case 'redeem':
$event = 'pinapi_event_txn_redeem';
break;
}
// Invoke rules event.
if ( !is_null($event) ) {
try {
// Load wrapped user entity so we can act on the object.
$txn->user = entity_metadata_wrapper('user', $txn->uid);
// Invoke rules event.
rules_invoke_event($event, $txn);
}
catch ( EntityMetadataWrapperException $e ) {
// @TODO: Add exception logic.
}
}
}