Pimcore\Helper\Mail::normalizeCssContent PHP Метод

normalizeCssContent() публичный статический Метод

Normalizes the css content (replaces images with the full path including the host)
public static normalizeCssContent ( string $content, array $fileInfo ) : string
$content string
$fileInfo array
Результат string
    public static function normalizeCssContent($content, array $fileInfo)
    {
        preg_match_all("@url\\s*\\(\\s*[\"']?(.*?)[\"']?\\s*\\)@is", $content, $matches);
        $hostUrl = Tool::getHostUrl();
        if (is_array($matches[0])) {
            foreach ($matches[0] as $key => $value) {
                $fullMatch = $matches[0][$key];
                $path = $matches[1][$key];
                if ($path[0] == '/') {
                    $imageUrl = $hostUrl . $path;
                } else {
                    $imageUrl = dirname($fileInfo['fileUrlNormalized']) . "/{$path}";
                    $netUrl = new \Net_URL2($imageUrl);
                    $imageUrl = $netUrl->getNormalizedURL();
                }
                $content = str_replace($fullMatch, " url(" . $imageUrl . ") ", $content);
            }
        }
        return $content;
    }