You are here

private static function Cleaner::cleanerFilesClear in Cleaner 7

Files cleaner handler.

Parameters

string $type: Type: CSS or JS.

2 calls to Cleaner::cleanerFilesClear()
Cleaner::cleanerCssClear in ./class.Cleaner.php
CSS files clearing handler.
Cleaner::cleanerJsClear in ./class.Cleaner.php
JS files clearing handler.

File

./class.Cleaner.php, line 238
Cleaner base class file.

Class

Cleaner
Class Cleaner.

Code

private static function cleanerFilesClear($type) {

  // Check if CSS/JS aggregation enabled.
  if (variable_get('preprocess_' . $type)) {
    $dir = drupal_realpath('public://' . $type);
    foreach (scandir($dir) as $file) {
      if (strpos($file, $type) !== FALSE) {
        $uri = 'public://' . $type . '/' . $file;
        if (REQUEST_TIME - filemtime($uri) > 3600) {
          file_unmanaged_delete($uri);
        }
      }
    }

    // Write a log about successful files clearing into the watchdog.
    self::cleanerLog('Cleared old temporary @type files by Cleaner', array(
      '@type' => drupal_strtoupper($type),
    ));
  }
  else {

    // Write a log about thing that CSS/JS aggregation isn't enabled.
    self::cleanerLog('Aggregation for @type files isn\'t enabled', array(
      '@type' => drupal_strtoupper($type),
    ), WATCHDOG_INFO, l(t('Settings'), url('admin/config/system/cleaner')));
  }
}