You are here

public function Webform::setState in Webform 8.5

Same name and namespace in other branches
  1. 6.x 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 3109

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);
}