You are here

public function FileBase::validateAllCache in Forena Reports 8

Same name and namespace in other branches
  1. 7.5 src/File/FileBase.php \Drupal\forena\File\FileBase::validateAllCache()

Called anytime we want to make sure the include cache is good and complete. Any file modifications will cause cache to be rebuild to be rebuilt.

Parameters

string $prefix: Prefix to load.

Return value

array cached entries.

1 call to FileBase::validateAllCache()
FileBase::getCacheEntry in src/File/FileBaseOld.php
Returns the cache entry based on a filename.

File

src/File/FileBaseOld.php, line 150
FileSystemBase.inc File toolbox for manipulating files contained tn the report directory.

Class

FileBase

Namespace

Drupal\forena\File

Code

public function validateAllCache($prefix = '') {

  // Make sure once per session.
  if (!$this->cache) {
    $cache = \Drupal::cache()
      ->get($this->cacheKey);
    if ($cache) {
      $this->cache = $cache->data;
    }
    $this->needSave = FALSE;
  }

  // Skip extra stuff after we've validated once.
  if ($this->validated) {
    return NULL;
  }

  // Load data form the cache
  // Save current paths away.
  $this
    ->setFilesToDelete();
  $this
    ->scan($prefix);
  $this
    ->_validateAllCache($prefix);

  //Rescan in case we found deleted files.
  if ($this->needScan) {
    $this
      ->scan($prefix);
    $this
      ->_validateAllCache($prefix);
  }

  //Remove any reports that have dissapeared.
  $this
    ->deleteMissingEntries();

  //Resave the cache if had to be altered.
  if ($this->needSave) {
    \Drupal::cache()
      ->set($this->cacheKey, $this->cache);
  }

  //$this->needScan = FALSE;
  $this->validated = TRUE;
}