You are here

protected function FileSystemBackend::ensureCacheFolderExists in File Cache 8

Verifies that the cache folder exists and is writable.

Throws

\Exception Thrown when the folder could not be created or is not writable.

4 calls to FileSystemBackend::ensureCacheFolderExists()
FileSystemBackend::doDeleteAll in src/Cache/FileSystemBackend.php
Deletes all cache items in the bin.
FileSystemBackend::garbageCollection in src/Cache/FileSystemBackend.php
Performs garbage collection on a cache bin.
FileSystemBackend::invalidateAll in src/Cache/FileSystemBackend.php
Marks all cache items as invalid.
FileSystemBackend::set in src/Cache/FileSystemBackend.php
Stores data in the persistent cache.

File

src/Cache/FileSystemBackend.php, line 316

Class

FileSystemBackend
A cache backend that stores cache items as files on the file system.

Namespace

Drupal\filecache\Cache

Code

protected function ensureCacheFolderExists() {
  if (!is_dir($this->path)) {
    if (!$this->fileSystem
      ->mkdir($this->path, 0755, TRUE)) {
      throw new \Exception('Could not create cache folder ' . $this->path);
    }
  }
  if (!is_writable($this->path)) {
    throw new \Exception('Cache folder ' . $this->path . ' is not writable.');
  }
}