You are here

protected function PageProcessor::processTagStyle in Mini site 8

Process <style> tag.

Parameters

\DOMNode $item: Document node object to process.

1 call to PageProcessor::processTagStyle()
PageProcessor::process in src/PageProcessor.php
Process document.

File

src/PageProcessor.php, line 211

Class

PageProcessor
Class PageProcessor.

Namespace

Drupal\minisite

Code

protected function processTagStyle(\DOMNode $item) {
  $content = $item->textContent;

  // Replace imported styles.
  preg_match_all('/@import url\\(([^)]+)\\)/i', $content, $matches, PREG_SET_ORDER);
  if (empty($matches)) {
    return;
  }
  foreach ($matches as $match) {
    if (count($match) != 2) {
      continue;
    }
    $url = $match[1];
    $url = self::urlExtractPath($url);
    $url = UrlValidator::relativeToRoot($url, $this->urlBag
      ->getAssetDir() . '/' . $this->urlBag
      ->getRootDir());
    $str = str_replace($match[1], $url, $match[0]);
    $content = str_replace($match[0], $str, $content);
  }
  $item->textContent = $content;
}