You are here

function rules_input_evaluator_php_prepare in Rules 6

Prepares the evalution.

Parameters

$string: The string to evaluate later.

$variables: An array of available variables.

Return value

Arbitrary data, which is passed to the evaluator on evaluation. If NULL is returned the input evaluator will be skipped later.

Related topics

2 calls to rules_input_evaluator_php_prepare()
rules_action_custom_php_submit in rules/modules/php.rules_forms.inc
Execute custom php code action configuration form.
rules_condition_custom_php_submit in rules/modules/php.rules_forms.inc
Execute custom php code action configuration form.

File

rules/modules/php.rules.inc, line 36
rules integration for the php module This provides an php input evaluator as well as a execute php code action.

Code

function rules_input_evaluator_php_prepare($string, $variables) {
  if (strpos($string, '<?') !== FALSE) {
    $used_vars = array();
    foreach ($variables as $name => $info) {
      if (strpos($string, '$' . $name) !== FALSE) {
        $used_vars[] = $name;
      }
    }
    return $used_vars;
  }
}