You are here

function cache_actions_action_clear_panels_page_cache in Cache Actions 7

Same name and namespace in other branches
  1. 6.2 cache_actions.rules.inc \cache_actions_action_clear_panels_page_cache()
  2. 6 cache_actions.rules.inc \cache_actions_action_clear_panels_page_cache()

Clear the cache of the specified panel page.

Parameters

int $did the display id:

2 string references to 'cache_actions_action_clear_panels_page_cache'
cache_actions_rules_action_info in ./cache_actions.rules.inc
Implementation of hook_rules_action_info().
cache_actions_test_rules_defaults in cache_actions_test/cache_actions_test.rules_defaults.inc
Implementation of hook_rules_defaults(). Below are the rules needed for the testing.

File

./cache_actions.rules.inc, line 397
This file provides the rules integration for this module.

Code

function cache_actions_action_clear_panels_page_cache($handlers) {
  if (module_exists('page_manager') && module_exists('panels')) {

    // If this is an array, then this is one of the new rules.
    if (is_array($handlers)) {
      ctools_include('plugins', 'panels');
      foreach ($handlers as $handler) {
        if (is_numeric($handler)) {
          $display = panels_load_display($handler);
        }
        else {
          $display = _cache_actions_get_display_from_key($handler);
        }
        if (is_object($display)) {
          panels_clear_cached_content($display);
        }
        else {
          watchdog('cache_actions', "The panel variant %panel doesn't exist.\n            You need to look over your rules and see if there's any rules\n            involving that panel.", array(
            '%panel' => $handler,
          ), WATCHDOG_ERROR);
        }
      }
    }
    else {
      $display = panels_load_display($handlers);
      if (is_object($display)) {
        panels_clear_cached_content($display);
      }
      else {
        watchdog('cache_actions', "The panel variant %panel doesn't exist.\n            You need to look over your rules and see if there's any rules\n            involving that panel.", array(
          '%panel' => $handler,
        ), WATCHDOG_ERROR);
      }
    }
  }
}