public function DataComparison::processInternalVariables in Business Rules 2.x
Same name and namespace in other branches
- 8 src/Plugin/BusinessRulesCondition/DataComparison.php \Drupal\business_rules\Plugin\BusinessRulesCondition\DataComparison::processInternalVariables()
Process the item replacing the variables by it's values.
Parameters
mixed $values_to_compare: The item to be replaced by the variable value.
\Drupal\business_rules\VariablesSet $variables: Array of Variables provided by the event.
Return value
mixed The processed content, replacing the variables tokens for it's values.
1 call to DataComparison::processInternalVariables()
- DataComparison::process in src/
Plugin/ BusinessRulesCondition/ DataComparison.php - Process the condition.
File
- src/
Plugin/ BusinessRulesCondition/ DataComparison.php, line 187
Class
- DataComparison
- Class DataComparison.
Namespace
Drupal\business_rules\Plugin\BusinessRulesConditionCode
public function processInternalVariables($values_to_compare, VariablesSet $variables) {
/** @var \Drupal\business_rules\VariableObject $variable */
if ($variables
->count()) {
foreach ($variables
->getVariables() as $variable) {
if (!is_array($variable
->getValue())) {
foreach ($values_to_compare as $key => $value_to_compare) {
$value = $variable
->getValue();
if (is_string($value) || is_numeric($value)) {
$values_to_compare[$key] = str_replace('{{' . $variable
->getId() . '}}', $value, $value_to_compare);
}
}
}
else {
foreach ($values_to_compare as $key => $value_to_compare) {
foreach ($variable
->getValue() as $item) {
// Add each value from variable array.
$values_to_compare[] = $item;
}
// Unset the variable id from $values_to_compare.
$variable_key = array_keys($values_to_compare, '{{' . $variable
->getId() . '}}');
foreach ($variable_key as $key) {
unset($values_to_compare[$key]);
}
}
}
}
}
return $values_to_compare;
}