-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrules_web_hook.api.php
130 lines (119 loc) · 2.91 KB
/
rules_web_hook.api.php
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
// $Id$
/**
* @file
* This file contains no working PHP code; it exists to provide additional
* documentation for doxygen as well as to document hooks in the standard
* Drupal manner.
*/
/**
* @addtogroup rules_hooks
* @{
*/
/**
* Act on rules web hooks being loaded from the database.
*
* This hook is invoked during rules web hooks loading, which is handled by
* entity_load(), via the EntityCRUDController.
*
* @param $hooks
* An array of rules web hooks being loaded, keyed by id.
*/
function hook_rules_web_hook_load($hooks) {
$result = db_query('SELECT id, foo FROM {mytable} WHERE id IN(:ids)', array(':ids' => array_keys($hooks)));
foreach ($result as $record) {
$hooks[$record->id]->foo = $record->foo;
}
}
/**
* Respond to creation of a new rules web hook.
*
* This hook is invoked after the rules web hook is inserted into the database.
*
* @param EntityDB $hook
* The rules web hook that is being created.
*/
function hook_rules_web_hook_insert($hook) {
db_insert('mytable')
->fields(array(
'id' => $hook->id,
'my_field' => $hook->myField,
))
->execute();
}
/**
* Act on a rules web hooks being inserted or updated.
*
* This hook is invoked before the rules web hook is saved to the database.
*
* @param EntityDB $hook
* The rules web hook that is being inserted or updated.
*/
function hook_rules_web_hook_presave($hook) {
$hook->myField = 'foo';
}
/**
* Respond to updates to a rules web hook.
*
* This hook is invoked after the web hook has been updated in the database.
*
* @param EntityDB $hook
* The rules web hook that is being updated.
*/
function hook_rules_web_hook_update($hook) {
db_update('mytable')
->fields(array('my_field' => $hook->myField))
->condition('id', $hook->id)
->execute();
}
/**
* Respond to a rules web hook deletion.
*
* This hook is invoked after the web hook has been removed from the database.
*
* @param EntityDB $hook
* The rules web hook that is being deleted.
*/
function hook_rules_web_hook_delete($hook) {
db_delete('mytable')
->condition('id', $hook->id)
->execute();
}
/**
* Define default rules web hooks.
*
* This hook is invoked when rules web hooks are loaded.
*
* @return
* An array of rules web hooks with the hook names as keys.
*
* @see hook_default_rules_web_hook_alter()
*/
function hook_default_rules_web_hook() {
$hook = new EntityDB(array(), 'rules_web_hook');
$hook->name = 'test';
$hook->label = 'A test hook.';
$hook->active = TRUE;
$hook->variables = array(
'node' => array(
'type' => 'node',
'label' => 'Content',
),
);
$hooks[$hook->name] = $hook;
return $hooks;
}
/**
* Alter default web hooks.
*
* @param $hooks
* The default hooks of all modules as returned from
* hook_default_rules_web_hook().
*
* @see hook_default_rules_web_hook()
*/
function hook_default_rules_web_hook_alter(&$hooks) {
}
/**
* @}
*/