You are here

public function Webform::getState in Webform 6.x

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

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

Parameters

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

mixed $default: The default value to use if the key is not found.

Return value

mixed The stored value, or NULL if no value exists.

Overrides WebformInterface::getState

File

src/Entity/Webform.php, line 3101

Class

Webform
Defines the webform entity.

Namespace

Drupal\webform\Entity

Code

public function getState($key, $default = NULL) {
  $namespace = 'webform.webform.' . $this
    ->id();
  $values = \Drupal::state()
    ->get($namespace, []);
  return isset($values[$key]) ? $values[$key] : $default;
}