You are here

public function Webform::getState in Webform 8.5

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

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