Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / system / tests / modules / mail_html_test / src / Plugin / Mail / TestHtmlMailCollector.php
diff --git a/web/core/modules/system/tests/modules/mail_html_test/src/Plugin/Mail/TestHtmlMailCollector.php b/web/core/modules/system/tests/modules/mail_html_test/src/Plugin/Mail/TestHtmlMailCollector.php
new file mode 100644 (file)
index 0000000..43e4135
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+
+namespace Drupal\mail_html_test\Plugin\Mail;
+
+use Drupal\Core\Mail\MailFormatHelper;
+use Drupal\Core\Mail\Plugin\Mail\TestMailCollector;
+
+/**
+ * Defines a mail backend that captures sent HTML messages in the state system.
+ *
+ * This class is for running tests or for development and does not convert HTML
+ * to plaintext.
+ *
+ * @Mail(
+ *   id = "test_html_mail_collector",
+ *   label = @Translation("HTML mail collector"),
+ *   description = @Translation("Does not send the message, but stores its HTML in Drupal within the state system. Used for testing.")
+ * )
+ */
+class TestHtmlMailCollector extends TestMailCollector {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function format(array $message) {
+    // Join the body array into one string.
+    $message['body'] = implode(PHP_EOL, $message['body']);
+    // Wrap the mail body for sending.
+    $message['body'] = MailFormatHelper::wrapMail($message['body']);
+    return $message;
+  }
+
+}