You are here

public function VariablesSet::replaceValue in Business Rules 8

Same name and namespace in other branches
  1. 2.x src/VariablesSet.php \Drupal\business_rules\VariablesSet::replaceValue()

Replace the content of one variable.

@internal param \Drupal\business_rules\VariableObject $variable

Parameters

string $variable_id: The variable id.

mixed $value: The variable value.

File

src/VariablesSet.php, line 39

Class

VariablesSet
Class VariablesSet to be returned on each BusinessRulesVariable plugin.

Namespace

Drupal\business_rules

Code

public function replaceValue($variable_id, $value) {
  if ($this
    ->count()) {
    foreach ($this->variables as $key => $var) {
      if ($var
        ->getId() == $variable_id) {
        $this->variables[$key]
          ->setValue($value);
      }
    }
  }
}