public function Webform::setUserData in Webform 8.5
Same name and namespace in other branches
- 6.x src/Entity/Webform.php \Drupal\webform\Entity\Webform::setUserData()
Saves a value for a given key in the webform's user data.
Parameters
string $key: The key of the data to store.
mixed $value: The data to store.
Overrides WebformInterface::setUserData
File
- src/
Entity/ Webform.php, line 3153
Class
- Webform
- Defines the webform entity.
Namespace
Drupal\webform\EntityCode
public function setUserData($key, $value) {
$account = \Drupal::currentUser();
/** @var \Drupal\user\UserDataInterface $user_data */
$user_data = \Drupal::service('user.data');
$values = $user_data
->get('webform', $account
->id(), $this
->id()) ?: [];
$values[$key] = $value;
$user_data
->set('webform', $account
->id(), $this
->id(), $values);
}