function ffc_condition_execute_rules_event in Field formatter conditions 7
Execute a rules event.
File
- ./
ffc.module, line 250 - Field formatter conditions.
Code
function ffc_condition_execute_rules_event(&$build, $source, $configuration, $context) {
$rule_event = $configuration['rule'];
if ($rule = entity_load('rules_config', array(
$rule_event,
))) {
$rule = reset($rule);
$state = new RulesState();
$FFCElement = new FFCElement($build);
$state
->addVariable($context['entity_type'], $context['entity'], array(
'type' => $context['entity_type'],
));
$state
->addVariable('ffc_element', $FFCElement, array(
'type' => 'ffc_element',
));
$state
->addVariable('ffc_field', $source, array(
'type' => 'ffc_field',
));
// We pass in an empty variable. This is to 'trick' rules so it can
// evaluate the rule. This ffc_empty can be used in the action callback,
// to store information. Might need revision in case we want to add
// more in the future I guess.
$state
->addVariable('ffc_empty', '', array(
'type' => 'ffc_empty',
));
$rule
->evaluate($state);
// Only overwrite if there was an action fired.
if ($FFCElement->fired) {
$build = $FFCElement->element;
}
}
}