function RulesPHPEvaluator::evaluate

Evaluates PHP code contained in $text.

This method doesn't apply $options, thus the PHP code is responsible for behaving appropriately.

Parameters

string $text: The text to evaluate.

array $options: A keyed array of settings and flags to control the processing. Supported options are:

  • language: A language object to be used when processing.
  • callback: A callback function that will be used to post-process replacements that might be incorporated, so they can be cleaned in a certain way.
  • sanitize: A boolean flag indicating whether incorporated replacements should be sanitized.

RulesState $state: The rules evaluation state.

Return value

The evaluated text.

Overrides RulesDataInputEvaluator::evaluate

File

modules/php.eval.inc, line 58

Class

RulesPHPEvaluator
A class implementing a rules input evaluator processing PHP.

Code

public function evaluate($text, $options, RulesState $state) {
  $vars['eval_options'] = $options;
  foreach ($this->setting as $key => $var_name) {
    $vars[$var_name] = $state->get($var_name);
  }
  return rules_php_eval($text, rules_unwrap_data($vars));
}