You are here

protected function StaticGenerator::getCssAssets in Tome 8

Finds assets for the given CSS content.

Parameters

string $content: A CSS string.

string $root: A root path to resolve relative paths.

Return value

array An array of paths found in the given CSS string.

2 calls to StaticGenerator::getCssAssets()
StaticGenerator::exportPaths in modules/tome_static/src/StaticGenerator.php
Exports multiple paths.
StaticGenerator::getHtmlAssets in modules/tome_static/src/StaticGenerator.php
Finds and exports assets for the given HTML content.

File

modules/tome_static/src/StaticGenerator.php, line 338

Class

StaticGenerator
Handles static site generation.

Namespace

Drupal\tome_static

Code

protected function getCssAssets($content, $root) {
  $paths = [];

  // Regex copied from the Static module from Drupal 7.
  // Credit to Randall Knutson and Michael Vanetta.
  $matches = [];
  preg_match_all('/url\\(\\s*[\'"]?(?!(?:data)+:)([^\'")]+)[\'"]?\\s*\\)/i', $content, $matches);
  if (isset($matches[1])) {
    $paths = $matches[1];
  }
  $paths = $this
    ->getRealPaths($paths, $root);
  return $paths;
}