You are here

public function ExecutionState::setVariable in Rules 8.3

Sets a state variable based on its definition and value.

Parameters

string $name: The context variable name.

\Drupal\rules\Context\ContextDefinitionInterface $definition: The context definition of the variable.

mixed $value: The variable value.

Return value

$this

Overrides ExecutionStateInterface::setVariable

File

src/Context/ExecutionState.php, line 80

Class

ExecutionState
The rules execution state.

Namespace

Drupal\rules\Context

Code

public function setVariable($name, ContextDefinitionInterface $definition, $value) {
  $data = $this
    ->getTypedDataManager()
    ->create($definition
    ->getDataDefinition(), $value);
  $this
    ->setVariableData($name, $data);
  return $this;
}