From 37ce5b84d2760a8b56916c630bbfd3225ce611b9 Mon Sep 17 00:00:00 2001 From: bighappyface Date: Thu, 7 May 2020 13:14:34 -0500 Subject: [PATCH] Issue #3134549: Success Messages For Remote Post Handler --- .../WebformHandler/RemotePostWebformHandler.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Plugin/WebformHandler/RemotePostWebformHandler.php b/src/Plugin/WebformHandler/RemotePostWebformHandler.php index c94d5c935..f01031f7b 100644 --- a/src/Plugin/WebformHandler/RemotePostWebformHandler.php +++ b/src/Plugin/WebformHandler/RemotePostWebformHandler.php @@ -522,6 +522,19 @@ class RemotePostWebformHandler extends WebformHandlerBase { $message = $this->t('Remote post request return @status_code status code.', ['@status_code' => $status_code]); $this->handleError($state, $message, $request_url, $request_method, $request_type, $request_options, $response); return; + } else { + // Check for custom messages related to success codes. + if ($custom_response_message = $this->getCustomResponseMessage($response)) { + $token_data = [ + 'webform_handler' => [ + $this->getHandlerId() => $this->getResponseData($response), + ], + ]; + $build_message = [ + '#markup' => $this->replaceTokens($custom_response_message, $this->getWebform(), $token_data), + ]; + $this->messenger()->addMessage(\Drupal::service('renderer')->renderPlain($build_message)); + } } // If debugging is enabled, display the request and response. -- 2.24.2 (Apple Git-127)