You are here

function akamai_get_purge_paths in Akamai 7.3

Builds a list of paths to purge in addition to a given path.

The list includes the system path and path alias. The base path is included if the given path is set to the front page. Other modules may alter the list by implementing hook_akamai_paths_alter().

Parameters

string $path: The path being purged, such as "node/34".

array $options: (optional) Additional options used by the url() function.

The following options are not supported:

  • absolute
  • https
  • fragment

Return value

array An array of paths to submit to the CCU API.

2 calls to akamai_get_purge_paths()
akamai_clear_url in ./akamai.module
Deprecated. Use akamai_purge_path() instead.
akamai_purge_path in ./akamai.module
Purges a path and its related paths from Akamai's cache.

File

./akamai.module, line 341
Integration with Akamai CDN CCU API.

Code

function akamai_get_purge_paths($path, array $options) {
  $language_code = empty($options['language']->language) ? NULL : $options['language']->language;

  // Lookup system path.
  $path = drupal_get_normal_path($path, $language_code);

  // Build options array to pass to url(). We don't want absolute URLs or
  // or fragments in the URLs, so we prevent that here.
  $url_options = $options;
  $url_options['absolute'] = FALSE;
  if (isset($url_options['https'])) {
    unset($url_options['https']);
  }
  if (isset($url_options['fragment'])) {
    unset($url_options['fragment']);
  }

  // Build the list of paths to purge.
  $paths = [];

  // Add system path by instructing url() to not replace with the alias.
  $paths[] = url($path, $url_options + [
    'alias' => TRUE,
  ]);

  // Add aliased path.
  $paths[] = url($path, $url_options);

  // Check if this path is configured as the frontpage.
  if ($path == variable_get('site_frontpage', 'node')) {
    $paths[] = url('<front>', $url_options);
  }

  // Allow other modules to add/modify paths to be cleared.
  $context = $options;
  $context['original_path'] = $path;
  drupal_alter('akamai_paths', $paths, $context);

  // Remove duplicates.
  $paths = array_unique($paths);
  return $paths;
}