You are here

function _magic_clear_cache in Magic 7

A helper function to clear the magic cache.

Parameters

mixed $theme (default: FALSE): The theme name, or FALSE to delete all caches.

array $types (default: array()): The type of caches to remove. May have an array keyed with 'css' or 'js' or leave empty to clear both.

1 call to _magic_clear_cache()
magic_extension_assets_theme_settings_form_submit in ./magic.module
Submit handler for the theme settings form.
1 string reference to '_magic_clear_cache'
magic_drush_cache_clear in ./magic.module
Implements hook_drush_cache_clear().

File

./magic.module, line 524
Keep Frontend DRY; sprinkle it with MAGIC!

Code

function _magic_clear_cache($theme = FALSE, $types = array()) {
  if ($theme) {

    // We are only clearing the cache for a specific theme, not all caches.
    if (empty($types) || $types['css'] == TRUE) {
      cache_clear_all($theme . '_css_', 'cache_magic', TRUE);
    }
    if (empty($types) || $types['js'] == TRUE) {
      cache_clear_all($theme . '_js_', 'cache_magic', TRUE);
    }
  }
  else {

    // No settings were passed, we will clear all caches.
    cache_clear_all(NULL, 'cache_magic');
  }
}