function ContextConfig::setValue

Sets a pre-defined value for the given context.

Parameters

string $context_name: The name of the context.

mixed $value: The value to set for the context. The value must be a valid value for the context's data type, unless a data processor takes care of processing it to a valid value.

Return value

$this

Throws

\Drupal\rules\Exception\LogicException Thrown if a context value and map are set for a given context at the same time.

File

src/Context/ContextConfig.php, line 89

Class

ContextConfig
Class for value objects helping with context configuration.

Namespace

Drupal\rules\Context

Code

public function setValue($context_name, $value) {
    if (isset($this->config['context_mapping'][$context_name])) {
        throw new LogicException("Cannot map a context value and pre-define it at the same time.");
    }
    $this->config['context_values'][$context_name] = $value;
    return $this;
}