You are here

function _akamai_get_all_paths in Akamai 8

Same name and namespace in other branches
  1. 8.2 akamai.module \_akamai_get_all_paths()
  2. 6.2 akamai.module \_akamai_get_all_paths()
  3. 6 akamai.module \_akamai_get_all_paths()
  4. 7 akamai.module \_akamai_get_all_paths()
  5. 7.2 akamai.module \_akamai_get_all_paths()

Return all system and alias paths for the provided URL.

@todo: seems like there should be a more abstracted means of getting the aliases; research and verify

Parameters

$url: The URL to find all aliases

$node: The Node for the URL being cleared if one exists, NULL otherwise

Return value

An array of all paths aliased to the provided URL.

1 call to _akamai_get_all_paths()
akamai_clear_url in ./akamai.module
Clear a URL from Akamai. Clears node/id and any url aliases.

File

./akamai.module, line 147
akamai.module Integration with the Akamai CDN Cache Control Web Service.

Code

function _akamai_get_all_paths($url, $node = NULL) {
  global $language;

  // If it is not a node path, get the system path
  if (strpos($url, 'node') !== 0) {
    $source = drupal_lookup_path('source', $url);
  }
  if (!isset($source) || !$source) {
    $source = $url;
  }
  $source = preg_replace("/^\\//", "", $source);
  $paths[] = $source;
  $result = db_query('SELECT alias FROM {url_alias} WHERE source = :source AND langcode IN (:language, :language_none)', array(
    ':source' => $source,
    ':language' => isset($language->language) ? $language->language : '',
    ':language_none' => Language::LANGCODE_NOT_SPECIFIED,
  ));
  foreach ($result as $record) {
    $paths[] = $record->alias;
  }

  // If this is the frontpage, add a blank to clear the root doc
  if ($source == \Drupal::config('system.site')
    ->get('page.front')) {
    $paths[] = '';
  }

  // Allow other modules to add/modify paths to be cleared
  drupal_alter('akamai_paths', $paths, $node);
  return $paths;
}