filecache.install in File Cache 8
Requirements hook for the File Cache module.
File
filecache.installView source
<?php
/**
* @file
* Requirements hook for the File Cache module.
*/
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\filecache\Cache\FileSystemBackend;
/**
* Implements hook_requirements().
*/
function filecache_requirements($phase) {
$requirements = [];
// Only report warnings during a runtime check. It's not important to already
// have cache bins configured during module installation.
if ($phase !== 'runtime') {
return $requirements;
}
// Check if any cache bins are using the file system cache backend.
$bins = array_filter(Cache::getBins(), function (CacheBackendInterface $backend) {
return $backend instanceof FileSystemBackend;
});
if (empty($bins)) {
$requirements['filecache_missing_bins'] = [
'title' => t('File Cache'),
'value' => t('No cache bins are set up to use the file system cache backend. Please follow the instructions in the README.'),
'severity' => REQUIREMENT_WARNING,
];
}
return $requirements;
}
Functions
Name | Description |
---|---|
filecache_requirements | Implements hook_requirements(). |