MatthiasMullie\Minify\CSS::importFiles PHP Метод

importFiles() защищенный Метод

Import files into the CSS, base64-ized.
protected importFiles ( string $source, string $content ) : string
$source string The file to import files for
$content string The CSS content to import files for
Результат string
    protected function importFiles($source, $content)
    {
        $extensions = array_keys($this->importExtensions);
        $regex = '/url\\((["\']?)((?!["\']?data:).*?\\.(' . implode('|', $extensions) . '))\\1\\)/i';
        if ($extensions && preg_match_all($regex, $content, $matches, PREG_SET_ORDER)) {
            $search = array();
            $replace = array();
            // loop the matches
            foreach ($matches as $match) {
                // get the path for the file that will be imported
                $path = $match[2];
                $path = dirname($source) . '/' . $path;
                $extension = $match[3];
                // only replace the import with the content if we're able to get
                // the content of the file, and it's relatively small
                if ($this->canImportFile($path) && $this->canImportBySize($path)) {
                    // grab content && base64-ize
                    $importContent = $this->load($path);
                    $importContent = base64_encode($importContent);
                    // build replacement
                    $search[] = $match[0];
                    $replace[] = 'url(' . $this->importExtensions[$extension] . ';base64,' . $importContent . ')';
                }
            }
            // replace the import statements
            $content = str_replace($search, $replace, $content);
        }
        return $content;
    }