You are here

function panelizer_panels_cache_save in Panelizer 7.2

Same name and namespace in other branches
  1. 6 panelizer.module \panelizer_panels_cache_save()
  2. 7.3 panelizer.module \panelizer_panels_cache_save()
  3. 7 panelizer.module \panelizer_panels_cache_save()

Save all changes made to a display using the Page Manager page cache.

File

./panelizer.module, line 924
The Panelizer module attaches panels to entities, providing default panels and allowing each panel to be configured independently by privileged users.

Code

function panelizer_panels_cache_save($argument, $cache) {
  list($entity_type, $key) = explode(':', $argument, 2);
  $type = $entity_type;
  if ($entity_type == 'default') {
    list($entity_type, $bundle, $name) = @explode(':', $key, 3);
    $get_default = TRUE;
  }
  $handler = panelizer_entity_plugin_get_handler($entity_type);
  if (!$handler) {
    return;
  }
  if (!empty($get_default)) {
    $panelizer = $handler
      ->get_default_panelizer_object($bundle, $name);
    $panelizer->display = $cache->display;
    ctools_include('export');
    ctools_export_crud_save('panelizer_defaults', $panelizer);
  }
  else {
    $entities = entity_load($entity_type, array(
      $key,
    ));
    if ($entities[$key] && $entities[$key]->panelizer) {
      $entities[$key]->panelizer->display = $cache->display;
      $entities[$key]->panelizer->display_is_modified = TRUE;
      $handler
        ->entity_save($entities[$key]);
    }
  }
  panelizer_panels_cache_clear($argument, $cache);
}