W3cubDocs

/Drupal 8

protected static function MailFormatHelper::htmlToMailUrls

protected static MailFormatHelper::htmlToMailUrls($match = NULL, $reset = FALSE)

Keeps track of URLs and replaces them with placeholder tokens.

Callback for preg_replace_callback() within \Drupal\Core\Mail\MailFormatHelper::htmlToText().

File

core/lib/Drupal/Core/Mail/MailFormatHelper.php, line 333

Class

MailFormatHelper
Defines a class containing utility methods for formatting mail messages.

Namespace

Drupal\Core\Mail

Code

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 = array();
  }
  else {
    if (empty(static::$regexp)) {
      static::$regexp = '@^' . preg_quote($base_path, '@') . '@';
    }
    if ($match) {
      list(, , $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;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Mail!MailFormatHelper.php/function/MailFormatHelper::htmlToMailUrls/8.1.x