class BoostCacheFile in Boost 8
BoostCacheFile class.
Hierarchy
- class \Drupal\boost\BoostCacheFile
Expanded class hierarchy of BoostCacheFile
1 file declares its use of BoostCacheFile
- BoostCacheHandler.php in src/
BoostCacheHandler.php - Contains Drupal\boost\BoostCacheHandler.
File
- src/
BoostCacheFile.php, line 17 - Contains Drupal\boost\BoostCacheFile
Namespace
Drupal\boostView source
class BoostCacheFile {
/**
* Default mode for new directories.
*/
const CHMOD_DIRECTORY = 0775;
/**
* The file uri.
*/
protected $uri;
/**
* @var \Drupal\Core\File\FileSystem
*/
protected $filesystem;
/**
* @param \Drupal\Core\File\FileSystem $filesystem
* Provides helpers to operate on files and stream wrappers.
*/
public function __construct(FileSystem $filesystem) {
$this->filesystem = $filesystem;
}
/**
* Load file contents by uri.
* @param $uri string
*/
public function load($uri) {
return file_get_contents($uri);
}
/**
* Create new cache file.
* @param string $uri
* @param string $content
*/
public function save($uri, $content) {
$this
->directory($uri);
$this
->modify($uri, $content);
}
/**
* Delete cache file by uri.
* @param string $uri
*/
public function delete($uri) {
return $this->filesystem
->unlink($uri);
}
/**
* Make directory.
* @param string $uri
*/
private function directory($uri) {
$dir = $this->filesystem
->dirname($uri);
if (!file_exists($dir)) {
$this->filesystem
->mkdir($dir, static::CHMOD_DIRECTORY, TRUE);
}
}
/**
* Overrite existing cache file.
* @param string $uri
* @param string $content
*/
private function modify($uri, $content) {
return file_unmanaged_save_data($content, $uri, FILE_EXISTS_REPLACE);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BoostCacheFile:: |
protected | property | ||
BoostCacheFile:: |
protected | property | The file uri. | |
BoostCacheFile:: |
constant | Default mode for new directories. | ||
BoostCacheFile:: |
public | function | Delete cache file by uri. | |
BoostCacheFile:: |
private | function | Make directory. | |
BoostCacheFile:: |
public | function | Load file contents by uri. | |
BoostCacheFile:: |
private | function | Overrite existing cache file. | |
BoostCacheFile:: |
public | function | Create new cache file. | |
BoostCacheFile:: |
public | function |