You are here

public function StaticCache::filterUncachedPaths in Tome 8

Filters paths that are uncached from a given array.

@returns array An array of uncached paths.

Parameters

string $base_url: The base scheme/host for this request.

array $original_paths: An array of paths.

Overrides StaticCacheInterface::filterUncachedPaths

File

modules/tome_static/src/StaticCache.php, line 36

Class

StaticCache
Determines if pages are statically cached.

Namespace

Drupal\tome_static

Code

public function filterUncachedPaths($base_url, array $original_paths) {
  $this
    ->ensureBinExists();
  $cid_map = [];
  foreach ($original_paths as $original_path) {
    $cid_map[$this
      ->getCacheId($base_url, $original_path)] = $original_path;
  }
  $never_cache = Settings::get('tome_static_cache_exclude', []);
  $cids = array_keys($cid_map);
  foreach ($this
    ->getMultiple($cids) as $cid => $cache) {
    $skip = FALSE;
    foreach ($never_cache as $pattern) {
      if ($cid_map[$cid] === $pattern || @preg_match($pattern, $cid_map[$cid])) {
        $skip = TRUE;
        break;
      }
    }
    if (!$skip && file_exists($cache->data)) {
      unset($cid_map[$cid]);
    }
  }
  return array_values($cid_map);
}