You are here

protected function HTMLMailMime::attachRegex in HTML Mail 8

Same name and namespace in other branches
  1. 8.3 src/Utility/HtmlMailMime.php \Drupal\htmlmail\Utility\HtmlMailMime::attachRegex()

A preg_replace_callback used to attach local files, if possible.

See also

get()

File

src/Utility/HTMLMailMime.php, line 379
Provides the MailMIME class for creating MIME-formatted email messages.

Class

HTMLMailMime
Class HTMLMailMime.

Namespace

Drupal\htmlmail\Utility

Code

protected function attachRegex($matches) {
  if (($url = UrlHelper::stripDangerousProtocols($matches[4])) && ($path = self::$fileSystem
    ->realpath($url)) && is_file($path) && $this
    ->addHtmlImage($path)) {

    // The parent method will replace this with the actual cid: string.
    $matches[4] = $path;
  }
  return implode('', array_slice($matches, 1));
}