You are here

public function StaticGenerator::exportPaths in Tome 8

Exports multiple paths.

If a path is a file that already exists, it will be immediately copied. If a path needs to be fetched in a new request, it will be returned.

Parameters

string[] $paths: An array of paths to export.

Return value

string[] An array of paths that need to be fetched in new requests. Usually these are image style derivatives.

Overrides StaticGeneratorInterface::exportPaths

File

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

Class

StaticGenerator
Handles static site generation.

Namespace

Drupal\tome_static

Code

public function exportPaths(array $paths) {
  $paths = array_diff($paths, $this
    ->getExcludedPaths());
  $paths = array_values(array_unique($paths));
  $invoke_paths = [];
  foreach ($paths as $path) {
    $path = $this
      ->makeExternalUrlLocal($path);
    if (UrlHelper::isExternal($path)) {
      continue;
    }
    $destination = $this
      ->getDestination($path);
    $sanitized_path = $this
      ->sanitizePath($path);
    if ($this
      ->copyPath($sanitized_path, $destination)) {
      if (pathinfo($destination, PATHINFO_EXTENSION) === 'css') {
        $css_assets = $this
          ->getCssAssets(file_get_contents($destination), $sanitized_path);
        $invoke_paths = array_merge($invoke_paths, $this
          ->exportPaths($css_assets));
      }
    }
    else {
      $invoke_paths[] = $path;
    }
  }
  return $this
    ->filterInvokePaths($invoke_paths, $this->currentRequest);
}