public function CachedFormulaLoader::load

Loads formulae from a resource.

Formulae should be loaded the same regardless of the current debug mode. Debug considerations should happen downstream.

Parameters

ResourceInterface $resource A resource:

Return value

array An array of formulae

Overrides FormulaLoaderInterface::load

File

drupal/core/vendor/kriswallsmith/assetic/src/Assetic/Factory/Loader/CachedFormulaLoader.php, line 48

Class

CachedFormulaLoader
Adds a caching layer to a loader.

Namespace

Assetic\Factory\Loader

Code

public function load(ResourceInterface $resources) {
  if (!$resources instanceof IteratorResourceInterface) {
    $resources = array(
      $resources,
    );
  }
  $formulae = array();
  foreach ($resources as $resource) {
    $id = (string) $resource;
    if (!$this->configCache
      ->has($id) || $this->debug && !$resource
      ->isFresh($this->configCache
      ->getTimestamp($id))) {
      $formulae += $this->loader
        ->load($resource);
      $this->configCache
        ->set($id, $formulae);
    }
    else {
      $formulae += $this->configCache
        ->get($id);
    }
  }
  return $formulae;
}