You are here

function filecache_requirements in File Cache 8

Same name and namespace in other branches
  1. 7 filecache.module \filecache_requirements()

Implements hook_requirements().

File

./filecache.install, line 15
Requirements hook for the File Cache module.

Code

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;
}