You are here

public function Webform::setState in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Entity/Webform.php \Drupal\webform\Entity\Webform::setState()

Saves a value for a given key in the webform's state.

Parameters

string $key: The key of the data to store.

mixed $value: The data to store.

Overrides WebformInterface::setState

File

src/Entity/Webform.php, line 3110

Class

Webform
Defines the webform entity.

Namespace

Drupal\webform\Entity

Code

public function setState($key, $value) {
  $namespace = 'webform.webform.' . $this
    ->id();
  $values = \Drupal::state()
    ->get($namespace, []);
  $values[$key] = $value;
  \Drupal::state()
    ->set($namespace, $values);
}