You are here

function cache_actions_panels_display_save in Cache Actions 7.2

Implements hook_panels_display_save(). Updates any rules where we might have updated our cache keys.

1 call to cache_actions_panels_display_save()
cache_actions_update_7201 in ./cache_actions.install
Upgrade all old panels rules to the new format.

File

./cache_actions.module, line 97
This is the module file. It contains hooks for panels and views.

Code

function cache_actions_panels_display_save($display) {
  if (isset($display->cache_key)) {
    $cache_actions_updated_panes = variable_get('cache_actions_updated_panes', array());
    if (isset($cache_actions_updated_panes[$display->cache_key])) {
      $rules = entity_load('rules_config');
      foreach ($cache_actions_updated_panes[$display->cache_key] as $new_key => $old_key) {
        foreach ($rules as $rule) {
          if (in_array('cache_actions', $rule
            ->dependencies())) {
            foreach ($rule
              ->actions() as $action) {
              if (isset($action->settings['panes'][$old_key])) {
                unset($action->settings['panes'][$old_key]);
                $action->settings['panes'][$new_key] = $new_key;
                $action
                  ->save();
                $rule_changed = TRUE;
              }
            }
          }
        }
      }
      unset($cache_actions_updated_panes[$display->cache_key]);
      variable_set('cache_actions_updated_panes', $cache_actions_updated_panes);
    }
  }
}