public function Webform::getUserData in Webform 8.5
Same name and namespace in other branches
- 6.x src/Entity/Webform.php \Drupal\webform\Entity\Webform::getUserData()
Returns the stored value for a given key in the webform's user data.
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::getUserData
File
- src/
Entity/ Webform.php, line 3142
Class
- Webform
- Defines the webform entity.
Namespace
Drupal\webform\EntityCode
public function getUserData($key, $default = NULL) {
$account = \Drupal::currentUser();
/** @var \Drupal\user\UserDataInterface $user_data */
$user_data = \Drupal::service('user.data');
$values = $user_data
->get('webform', $account
->id(), $this
->id());
return isset($values[$key]) ? $values[$key] : $default;
}