-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrules_web_hook.rules.inc
More file actions
34 lines (30 loc) · 961 Bytes
/
rules_web_hook.rules.inc
File metadata and controls
34 lines (30 loc) · 961 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
<?php
// $Id$
/**
* @file Rules Web Hooks - Rules integration.
*/
/**
* Implements hook_rules_action_info().
*/
function rules_web_hook_rules_action_info() {
$return = array();
foreach (entity_load('rules_web_hook', FALSE) as $name => $hook) {
$return['web_hook_invoke_' . $name] = array(
'label' => t('Invoke "@label"', array('@label' => $hook->label)),
'named parameter' => TRUE,
'group' => t('Rules web hook'),
'base' => 'rules_web_hook_action_invoke',
'parameter' => $hook->variables,
);
}
return $return;
}
/**
* Action callback: Invoke a web hook.
*/
function rules_web_hook_action_invoke($args, RulesAbstractPlugin $element) {
$hook = rules_web_hook_load(substr($element->getElementName(), 16));
// Use the args in the state so we can reuse existing rules data wrapper.
$vars = array_intersect_key($args['state']->currentArguments, $hook->variables);
rules_web_hook_invoke($hook, $vars);
}