You are here

protected function RemotePostWebformHandler::getCustomResponseMessage in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Plugin/WebformHandler/RemotePostWebformHandler.php \Drupal\webform\Plugin\WebformHandler\RemotePostWebformHandler::getCustomResponseMessage()

Get custom response message.

Parameters

\Psr\Http\Message\ResponseInterface|null $response: The response returned by the remote server.

bool $default: Display the default message. Defaults to TRUE.

Return value

string A custom response message.

1 call to RemotePostWebformHandler::getCustomResponseMessage()
RemotePostWebformHandler::displayCustomResponseMessage in src/Plugin/WebformHandler/RemotePostWebformHandler.php
Display custom response message.

File

src/Plugin/WebformHandler/RemotePostWebformHandler.php, line 1136

Class

RemotePostWebformHandler
Webform submission remote post handler.

Namespace

Drupal\webform\Plugin\WebformHandler

Code

protected function getCustomResponseMessage($response, $default = TRUE) {
  if (!empty($this->configuration['messages']) && $response instanceof ResponseInterface) {
    $status_code = $response
      ->getStatusCode();
    foreach ($this->configuration['messages'] as $message_item) {
      if ((int) $message_item['code'] === (int) $status_code) {
        return $message_item['message'];
      }
    }
  }
  return !empty($this->configuration['message']) && $default ? $this->configuration['message'] : '';
}