function RulesComponent::setContextValue

Sets the value of a context.

Parameters

string $name: The name.

mixed $value: The context value.

Return value

$this

Throws

\Drupal\rules\Exception\LogicException Thrown if the passed context is not defined.

1 call to RulesComponent::setContextValue()
RulesComponent::executeWithArguments in src/Engine/RulesComponent.php
Executes the component with the given values.

File

src/Engine/RulesComponent.php, line 218

Class

RulesComponent
Handles executable Rules components.

Namespace

Drupal\rules\Engine

Code

public function setContextValue($name, $value) {
    if (!isset($this->contextDefinitions[$name])) {
        throw new LogicException("The specified context '{$name}' is not defined.");
    }
    $this->state
        ->setVariable($name, $this->contextDefinitions[$name], $value);
    return $this;
}