You are here

public function WebformElementController::close in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Controller/WebformElementController.php \Drupal\webform\Controller\WebformElementController::close()

Returns response for message close using user or state storage.

Parameters

string $storage: Mechanism that the message state should be stored in, user or state.

string $id: The unique id of the message.

Return value

\Drupal\Core\Ajax\AjaxResponse An empty Ajax response.

Throws

\Exception Throws exception is storage is not set to 'user' or 'state'.

See also

\Drupal\webform\Element\WebformMessage::setClosed

1 string reference to 'WebformElementController::close'
webform.routing.yml in ./webform.routing.yml
webform.routing.yml

File

src/Controller/WebformElementController.php, line 35

Class

WebformElementController
Provides route responses for Webform elements.

Namespace

Drupal\webform\Controller

Code

public function close($storage, $id) {
  if (!in_array($storage, [
    WebformMessage::STORAGE_USER,
    WebformMessage::STORAGE_STATE,
    WebformMessage::STORAGE_CUSTOM,
  ])) {
    throw new \Exception('Undefined storage mechanism for Webform close message.');
  }
  WebformMessage::setClosed($storage, $id);
  return new AjaxResponse();
}