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;
}
doc_Drupal
2016-10-29 09:25:11
Comments
Leave a Comment

Please login to continue.