Created
July 21, 2017 15:12
-
-
Save flocondetoile/e4e45bfaec22f12b2233aef9b26c0823 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Massages the message body into the format expected for rendering. | |
* | |
* @param array $message | |
* The message. | |
* | |
* @return array | |
*/ | |
public function cleanBody(array $message) { | |
// Get default mail line endings and merge all lines in the e-mail body | |
// separated by the mail line endings. Keep Markup objects and escape others | |
// and then treat the result as safe markup. | |
$line_endings = Settings::get('mail_line_endings', PHP_EOL); | |
$message['body'] = Markup::create(implode($line_endings, array_map(function ($body) { | |
// If $item is not marked safe then it will be escaped. | |
return $body instanceOf MarkupInterface ? $body : Html::escape($body); | |
}, $message['body']))); | |
return $message; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment