You are here

function hook_webform_message_custom in Webform 6.x

Same name and namespace in other branches
  1. 8.5 webform.api.php \hook_webform_message_custom()

Act on a custom message being displayed, closed or reset.

@internal This is an experimental hook whose definition may change.

Parameters

string $operation: closed: Returns TRUE if the message is closed. close: Sets the message's state to closed. reset: Resets the message's closed state.

string $id: The message id.

Return value

mixed|bool TRUE if message is closed, else NULL

See also

\Drupal\webform\Element\WebformMessage::isClosed

\Drupal\webform\Element\WebformMessage::setClosed

\Drupal\webform\Element\WebformMessage::resetClosed

2 functions implement hook_webform_message_custom()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

webform_test_message_custom_webform_message_custom in tests/modules/webform_test_message_custom/webform_test_message_custom.module
Implements hook_webform_message_custom().
webform_webform_message_custom in ./webform.module
Implements hook_webform_message_custom().
3 invocations of hook_webform_message_custom()
WebformMessage::isClosed in src/Element/WebformMessage.php
Is message closed via User Data, State API, or Custom.
WebformMessage::resetClosed in src/Element/WebformMessage.php
Reset message closed via User Data, State API, or Custom.
WebformMessage::setClosed in src/Element/WebformMessage.php
Set message closed via User Data, State API, or Custom.

File

./webform.api.php, line 704
Hooks related to Webform module.

Code

function hook_webform_message_custom($operation, $id) {

  // Handle 'webform_test_message_custom' defined in
  // webform.webform.test_element_message.yml.
  if ($id === 'webform_test_message_custom') {
    switch ($operation) {
      case 'closed':
        return \Drupal::state()
          ->get($id, FALSE);
      case 'close':
        \Drupal::state()
          ->set($id, TRUE);
        return NULL;
      case 'reset':
        \Drupal::state()
          ->delete($id);
        return NULL;
    }
  }
}