You are here

function media_browser_plus_clear_views_cache in Media Browser Plus 7.3

Clears the cache for a specific view.

This method is copied from the cache_actions module.

Parameters

string $view_name: The name of the view to clear the cache.

4 calls to media_browser_plus_clear_views_cache()
media_browser_plus_form_taxonomy_overview_terms_submit in ./media_browser_plus.module
Submit handler for the taxonomy term overview list.
media_browser_plus_taxonomy_term_delete in ./media_browser_plus.module
Implements hook_taxonomy_term_delete().
media_browser_plus_taxonomy_term_insert in ./media_browser_plus.module
Implements hook_taxonomy_term_insert().
media_browser_plus_taxonomy_term_update in ./media_browser_plus.module
Implements hook_taxonomy_term_update().
1 string reference to 'media_browser_plus_clear_views_cache'
media_browser_plus_file_presave in ./media_browser_plus.file.inc
Implements hook_file_presave().

File

./media_browser_plus.module, line 905
Media Browser Plus - enhanced file management functions.

Code

function media_browser_plus_clear_views_cache($view_name) {
  $view = views_get_view($view_name);
  if (is_object($view)) {

    // Go through all displays and clear the cache.
    foreach ($view->display as $display) {

      // Set display handler.
      $view
        ->set_display($display->id);

      // If we don't have our own cache plugin, then we need to copy the cache
      // settings from default.
      if (!isset($display->display_options['cache']) && isset($view->display['default'])) {
        $display->display_options['cache'] = $view->display['default']->display_options['cache'];
      }
      $cache_plugin = views_get_plugin('cache', $display->display_options['cache']['type']);

      // If we have a cache plugin, then initiate it and flush the cache.
      if (isset($cache_plugin)) {
        $cache_plugin
          ->init($view, $display);
        $cache_plugin
          ->cache_flush();
      }
    }
  }
}