function entityform_invoke_rules in Entityform 7
Utility function to invoke Rules components.
Return value
array Return values of the invoked Rule Components
4 calls to entityform_invoke_rules()
- entityform_edit_form_validate in ./
entityform.admin.inc - Form API validate callback for the entityform form
- entityform_entity_insert in ./
entityform.module - Implements hook_entity_insert().
- entityform_entity_update in ./
entityform.module - Implements hook_entity_update().
- entityform_form_wrapper in ./
entityform.admin.inc - Form callback wrapper: create or edit a entityform.
File
- ./
entityform.module, line 1500 - Module for the Entityform Entity - a starting point to create your own Entity and associated administration interface
Code
function entityform_invoke_rules($entityform, $rule_setting) {
$entityform_type = entityform_type_load($entityform->type);
$return_values = array();
if (isset($entityform_type->data[$rule_setting]) && is_array($entityform_type->data[$rule_setting])) {
foreach ($entityform_type->data[$rule_setting] as $rule_name) {
// Only invoke if Rules exists.
// rules_invoke_component will always return false if the Rule doesn't exist.
if (rules_get_cache('comp_' . $rule_name)) {
$return_values[] = rules_invoke_component($rule_name, $entityform, $entityform_type);
}
else {
// Warn that Rule doesn't exist
$msg = t('Entityform Type %form references non-existing Rule component %component', array(
'%form' => $entityform->type,
'%component' => $rule_name,
));
watchdog('entityform', $msg);
if (user_access('administer entityform types')) {
// Warn on screen if user can fix this.
drupal_set_message($msg, 'warning');
}
}
}
}
return $return_values;
}