public static function WebformMessage::isClosed in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Element/WebformMessage.php \Drupal\webform\Element\WebformMessage::isClosed()
Is message closed via User Data, State API, or Custom.
Parameters
string $storage: The storage mechanism to check if a message is closed.
string $id: The ID of the message.
Return value
bool TRUE if the message is closed.
1 call to WebformMessage::isClosed()
- WebformMessage::preRenderWebformMessage in src/
Element/ WebformMessage.php - Create status message for rendering.
File
- src/
Element/ WebformMessage.php, line 172
Class
- WebformMessage
- Provides a render element for message.
Namespace
Drupal\webform\ElementCode
public static function isClosed($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, []);
return isset($values[$id]) ? TRUE : FALSE;
case static::STORAGE_USER:
/** @var \Drupal\user\UserDataInterface $user_data */
$user_data = \Drupal::service('user.data');
$values = $user_data
->get('webform', $account
->id(), $namespace) ?: [];
return isset($values[$id]) ? TRUE : FALSE;
case static::STORAGE_CUSTOM:
$result = \Drupal::moduleHandler()
->invokeAll('webform_message_custom', [
'closed',
$id,
]);
return array_filter($result) ? TRUE : FALSE;
}
return FALSE;
}