You are here

protected function FileSystemBackendFactory::getPathForBin in File Cache 8

Returns the path for the specified cache bin.

Parameters

string $bin: The cache bin for which to return the path.

Return value

string The path or URI to the folder where the cache files for the given bin will be stored.

Throws

\Exception Thrown when no path has been configured.

1 call to FileSystemBackendFactory::getPathForBin()
FileSystemBackendFactory::get in src/Cache/FileSystemBackendFactory.php
Returns the FileSystemBackend for the specified cache bin.

File

src/Cache/FileSystemBackendFactory.php, line 95

Class

FileSystemBackendFactory
Factory for creating FileSystemBackend cache backends.

Namespace

Drupal\filecache\Cache

Code

protected function getPathForBin($bin) {
  $settings = $this->settings
    ->get('filecache');

  // Look for a cache bin specific setting.
  if (isset($settings['directory']['bins'][$bin])) {
    $path = rtrim($settings['directory']['bins'][$bin], '/') . '/';
  }
  elseif (isset($settings['directory']['default'])) {
    $path = rtrim($settings['directory']['default'], '/') . '/' . $bin . '/';
  }
  else {
    throw new \Exception('No path has been configured for the file system cache backend.');
  }
  return $path;
}