diff --git a/src/Plugin/WebformHandler/EmailWebformHandler.php b/src/Plugin/WebformHandler/EmailWebformHandler.php index 6c425609..03410b7a 100644 --- a/src/Plugin/WebformHandler/EmailWebformHandler.php +++ b/src/Plugin/WebformHandler/EmailWebformHandler.php @@ -622,18 +622,25 @@ class EmailWebformHandler extends WebformHandlerBase implements WebformHandlerMe */ public function getMessage(WebformSubmissionInterface $webform_submission) { $token_data = []; - $token_options = [ - 'email' => TRUE, - 'excluded_elements' => $this->configuration['excluded_elements'], - 'ignore_access' => $this->configuration['ignore_access'], - 'exclude_empty' => $this->configuration['exclude_empty'], - 'html' => ($this->configuration['html'] && $this->supportsHtml()), - ]; $message = []; // Copy configuration to $message. foreach ($this->configuration as $configuration_key => $configuration_value) { + + $token_options = [ + 'email' => TRUE, + 'excluded_elements' => $this->configuration['excluded_elements'], + 'ignore_access' => $this->configuration['ignore_access'], + 'exclude_empty' => $this->configuration['exclude_empty'], + 'html' => ($this->configuration['html'] && $this->supportsHtml()), + ]; + + // Clear tokens from email values. + if (strpos($configuration_key, '_mail') !== FALSE) { + $token_options['clear'] = TRUE; + } + // Get configuration name (to, cc, bcc, from, name, subject, mail) // and type (mail, options, or text). list($configuration_name, $configuration_type) = (strpos($configuration_key, '_') !== FALSE) ? explode('_', $configuration_key) : [$configuration_key, 'text']; diff --git a/src/Tests/WebformTokenSubmissionValueTest.php b/src/Tests/WebformTokenSubmissionValueTest.php index 4bb95197..bbfb4ab4 100644 --- a/src/Tests/WebformTokenSubmissionValueTest.php +++ b/src/Tests/WebformTokenSubmissionValueTest.php @@ -9,7 +9,7 @@ use Drupal\webform\Entity\Webform; * * @group Webform */ -class WebformTokenSubmissionValue extends WebformTestBase { +class WebformTokenSubmissionValueTest extends WebformTestBase { /** * Modules to enable. diff --git a/src/WebformTokenManager.php b/src/WebformTokenManager.php index 438e43b1..fef31b09 100644 --- a/src/WebformTokenManager.php +++ b/src/WebformTokenManager.php @@ -68,10 +68,6 @@ class WebformTokenManager implements WebformTokenManagerInterface { return $text; } - // Default all webform related tokens to be cleared. - // @see \webform_tokens - $options += ['webform_clear' => TRUE]; - // Replace @deprecated [webform-submission] with [webform_submission]. $text = str_replace('[webform-submission:', '[webform_submission:', $text); diff --git a/src/WebformTokenManagerInterface.php b/src/WebformTokenManagerInterface.php index e977a9a3..250b6b9c 100644 --- a/src/WebformTokenManagerInterface.php +++ b/src/WebformTokenManagerInterface.php @@ -27,9 +27,6 @@ interface WebformTokenManagerInterface { * array of token replacements after they are generated. * - clear: A boolean flag indicating that tokens should be removed from the * final text if no replacement value can be generated. - * - webform_clear: A boolean flag indicating that only webform tokens - * should be removed from the final text if no replacement value can be - * generated. (Default is TRUE) * * @return string|array * Text or array with tokens replaced. diff --git a/tests/modules/webform_test/config/install/webform.webform.test_token_submission_value.yml b/tests/modules/webform_test/config/install/webform.webform.test_token_submission_value.yml index 397f8ac4..c5e7f2eb 100644 --- a/tests/modules/webform_test/config/install/webform.webform.test_token_submission_value.yml +++ b/tests/modules/webform_test/config/install/webform.webform.test_token_submission_value.yml @@ -238,12 +238,6 @@ settings:
webform:removed:token | [webform:removed:token] |
---|---|
ignored:token | [ignored:token] |