function RulesI18nStringEvaluator::process

Prepare the i18n-context string.

We have to use process() here instead of evaluate() because we need more context than evaluate() provides.

Overrides RulesDataInputEvaluator::process

File

rules_i18n/rules_i18n.rules.inc, line 156

Class

RulesI18nStringEvaluator
A class implementing a rules input evaluator processing tokens.

Code

public function process($value, $info, RulesState $state, RulesPlugin $element, $options = NULL) {
    $options = isset($options) ? $options : $this->getEvaluatorOptions($info, $state, $element);
    $value = isset($this->processor) ? $this->processor
        ->process($value, $info, $state, $element, $options) : $value;
    if (isset($element->root()->name)) {
        $config_name = $element->root()->name;
        $id = $element->elementId();
        $name = $info['#name'];
        $options['i18n context'] = "rules:rules_config:{$config_name}:{$id}:{$name}";
        return $this->evaluate($value, $options, $state);
    }
    return $value;
}