function MailFormatHelper::htmlToMailUrls
Same name in other branches
- 9 core/lib/Drupal/Core/Mail/MailFormatHelper.php \Drupal\Core\Mail\MailFormatHelper::htmlToMailUrls()
- 8.9.x core/lib/Drupal/Core/Mail/MailFormatHelper.php \Drupal\Core\Mail\MailFormatHelper::htmlToMailUrls()
- 11.x core/lib/Drupal/Core/Mail/MailFormatHelper.php \Drupal\Core\Mail\MailFormatHelper::htmlToMailUrls()
Keeps track of URLs and replaces them with placeholder tokens.
Callback for preg_replace_callback() within \Drupal\Core\Mail\MailFormatHelper::htmlToText().
1 call to MailFormatHelper::htmlToMailUrls()
- MailFormatHelper::htmlToText in core/
lib/ Drupal/ Core/ Mail/ MailFormatHelper.php - Transforms an HTML string into plain text, preserving its structure.
File
-
core/
lib/ Drupal/ Core/ Mail/ MailFormatHelper.php, line 326
Class
- MailFormatHelper
- Defines a class containing utility methods for formatting mail messages.
Namespace
Drupal\Core\MailCode
protected static function htmlToMailUrls($match = NULL, $reset = FALSE) {
// @todo Use request context instead.
global $base_url, $base_path;
if ($reset) {
// Reset internal URL list.
static::$urls = [];
}
else {
if (empty(static::$regexp)) {
static::$regexp = '@^' . preg_quote($base_path, '@') . '@';
}
if ($match) {
[
,
,
$url,
$label,
] = $match;
// Ensure all URLs are absolute.
static::$urls[] = strpos($url, '://') ? $url : preg_replace(static::$regexp, $base_url . '/', $url);
return $label . ' [' . count(static::$urls) . ']';
}
}
return static::$urls;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.