You are here

function minifyjs_load_all_files in Minify JS 7

Same name and namespace in other branches
  1. 8 minifyjs.module \minifyjs_load_all_files()

Helper function - load all of the minifyjs_file records from cache or directly from the database.

10 calls to minifyjs_load_all_files()
drush_minifyjs_minify_js in ./minifyjs.drush.inc
Drush command logic. drush_[COMMAND_NAME]().
drush_minifyjs_minify_js_skip in ./minifyjs.drush.inc
Drush command logic. drush_[COMMAND_NAME]().
minifyjs_form_system_performance_settings_alter in ./minifyjs.module
Implements hook_FORM_ID_alter().
minifyjs_js_alter in ./minifyjs.module
Implements hook_js_alter().
minifyjs_manage_javascript_files_form in ./minifyjs.admin.inc
Helper function for form table:

... See full list

File

./minifyjs.module, line 161

Code

function minifyjs_load_all_files() {

  // load files from cache
  if ($cached = cache_get(MINIFYJS_CACHE_CID)) {
    return $cached->data;
  }

  // re-build cache
  $result = db_select('minifyjs_file', 'f')
    ->fields('f')
    ->orderBy('uri')
    ->execute();
  $exclusions = variable_get('minifyjs_exclusion_list');
  $files = array();
  while ($file = $result
    ->fetchObject()) {

    // ignore exclusions
    if (!drupal_match_path($file->uri, $exclusions)) {
      $files[$file->fid] = $file;
    }
  }

  // cache for 1 day
  cache_set(MINIFYJS_CACHE_CID, $files, 'cache', strtotime('+1 day', REQUEST_TIME));
  return $files;
}