public static function WebformMessage::resetClosed in Webform 8.5
Same name and namespace in other branches
- 6.x src/Element/WebformMessage.php \Drupal\webform\Element\WebformMessage::resetClosed()
Reset message closed via User Data, State API, or Custom.
Parameters
string $storage: The storage mechanism save message closed.
string $id: The ID of the message.
See also
\Drupal\webform\Controller\WebformElementController::close
1 call to WebformMessage::resetClosed()
- WebformHelpManager::initHelp in src/
WebformHelpManager.php - Initialize help.
File
- src/
Element/ WebformMessage.php, line 241
Class
- WebformMessage
- Provides a render element for message.
Namespace
Drupal\webform\ElementCode
public static function resetClosed($storage, $id) {
$account = \Drupal::currentUser();
$namespace = 'webform.element.message';
switch ($storage) {
case static::STORAGE_STATE:
/** @var \Drupal\Core\State\StateInterface $state */
$state = \Drupal::service('state');
$values = $state
->get($namespace, []);
unset($values[$id]);
$state
->set($namespace, $values);
break;
case static::STORAGE_USER:
/** @var \Drupal\user\UserDataInterface $user_data */
$user_data = \Drupal::service('user.data');
$values = $user_data
->get('webform', $account
->id(), $namespace) ?: [];
unset($values[$id]);
$user_data
->set('webform', $account
->id(), $namespace, $values);
break;
case static::STORAGE_CUSTOM:
\Drupal::moduleHandler()
->invokeAll('webform_message_custom', [
'reset',
$id,
]);
break;
}
}