You are here

public function ExpirePanels::expire in Panels Cache Expiration 7

Executes expiration actions for panels.

Parameters

object $display: Panel display.

int $action: Action that has been executed.

bool $skip_action_check: Shows whether should we check executed action or just expire node.

Overrides ExpireInterface::expire

File

includes/expire.panels.inc, line 22
Provides class that expires panels.

Class

ExpirePanels
@file Provides class that expires panels.

Code

public function expire($display, $action, $skip_action_check = FALSE) {
  $panel_pane = $this
    ->getPanelPage($display);
  $enabled_actions = variable_get('expire_panels_actions', array());
  $enabled_actions = array_filter($enabled_actions);

  // Stop further expiration if executed action is not selected by admin.
  if (!in_array($action, $enabled_actions) && !$skip_action_check) {
    return;
  }
  $expire_urls = array();

  // Expire front page.
  $expire_front_page = variable_get('expire_panels_front_page', EXPIRE_PANELS_FRONT_PAGE);
  if ($expire_front_page) {
    $expire_urls = ExpireAPI::getFrontPageUrls();
  }

  // Expire panel page.
  $expire_panel_page = variable_get('expire_panels_panel_page', EXPIRE_PANELS_PANEL_PAGE);
  if (!empty($panel_pane->path) && $expire_panel_page) {
    $expire_urls['panel-' . $panel_pane->path] = $this
      ->placeholdersToWildcard($panel_pane->path);
  }

  // Expire panelizer page.
  // @todo currently supports only update.
  $expire_panelizer = variable_get('expire_panels_panelizer_page', EXPIRE_PANELS_PANELIZER_PAGE);
  if (module_exists('panelizer') && $expire_panelizer && !empty($display->context['panelizer'])) {
    $panelizer = $display->context['panelizer'];
    if (!empty($panelizer->type[2])) {
      $function = 'expire_' . $panelizer->type[2] . '_update';
      if (function_exists($function)) {
        $function($panelizer->data);
      }
    }
  }

  // Expire custom pages.
  $expire_custom = variable_get('expire_panels_custom', EXPIRE_PANELS_CUSTOM);
  if ($expire_custom) {
    $pages = variable_get('expire_panels_custom_pages');
    $urls = ExpireAPI::expireCustomPages($pages, array(
      'panel' => $display,
    ));
    $expire_urls = array_merge($expire_urls, $urls);
  }

  // Flush page cache for expired urls.
  ExpireAPI::executeExpiration($expire_urls, 'panels', $display);
}