Common\Mailer\Message::addUTM PHP Метод

addUTM() приватный Метод

private addUTM ( string $html, string $subject ) : string
$html string The html to convert links in.
$subject string The subject of the mail
Результат string
    private function addUTM($html, $subject)
    {
        // match links
        $matches = array();
        preg_match_all('/href="(http:\\/\\/(.*))"/iU', $html, $matches);
        // any links?
        $utm = array('utm_source' => 'mail', 'utm_medium' => 'email', 'utm_campaign' => Uri::getUrl($subject));
        if (isset($matches[0]) && !empty($matches[0])) {
            $searchLinks = array();
            $replaceLinks = array();
            // loop old links
            foreach ($matches[1] as $i => $link) {
                $searchLinks[] = $matches[0][$i];
                $replaceLinks[] = 'href="' . Model::addURLParameters($link, $utm) . '"';
            }
            $html = str_replace($searchLinks, $replaceLinks, $html);
        }
        return $html;
    }