protected function DataCalculateValue::doExecute in Rules 8.3
Executes the action with the given context.
Parameters
float $input_1: The first input value.
string $operator: The operator that should be applied.
float $input_2: The second input value.
File
- src/
Plugin/ RulesAction/ DataCalculateValue.php, line 52
Class
- DataCalculateValue
- Provides a 'numeric calculation' action.
Namespace
Drupal\rules\Plugin\RulesActionCode
protected function doExecute($input_1, $operator, $input_2) {
switch ($operator) {
case '+':
$result = $input_1 + $input_2;
break;
case '-':
$result = $input_1 - $input_2;
break;
case '*':
$result = $input_1 * $input_2;
break;
case '/':
$result = $input_1 / $input_2;
break;
case 'min':
$result = min($input_1, $input_2);
break;
case 'max':
$result = max($input_1, $input_2);
break;
}
if (isset($result)) {
$this
->setProvidedValue('result', $result);
}
}