You are here

function akamai_clear_url in Akamai 6.2

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

Clear a URL from Akamai. Clears node/id and any url aliases.

Parameters

array $paths_in: A array of paths or single path to clear

array $params: An array of params for the API call

Return value

bool TRUE if it was successfully cleared, FALSE otherwise.

3 calls to akamai_clear_url()
akamai_cache_control_submit in ./akamai.admin.inc
Submit handler for akamai_cache_control().
akamai_nodeapi in ./akamai.module
Implements hook_nodeapi().
akamai_page_cache_control_form_submit in ./akamai.module
Submit handler for akamai_page_cache_control.

File

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

Code

function akamai_clear_url($paths_in, $params = array(), $node = NULL) {
  if (!is_array($paths_in)) {
    $paths_in = array(
      $paths_in,
    );
  }

  // Get the system path and all aliases to this url.
  $paths = array();
  foreach ($paths_in as $path) {
    $paths = array_merge($paths, _akamai_get_all_paths($path, $node));
  }

  // It is possible to have no paths at this point if other modules have altered
  // the paths.
  if (empty($paths)) {
    watchdog('akamai', 'No resultant paths to clear for %paths', array(
      '%paths' => implode(', ', $paths_in),
    ), WATCHDOG_NOTICE);
    return FALSE;
  }
  $paths = array_unique($paths);

  // Setup the notification email if an email address is not provided.
  if (!array_key_exists('email', $params) || empty($params['email'])) {
    $params['email'] = akamai_get_notification_email();
  }
  try {
    $akamai = akamai_get_class($params);
    $response = $akamai
      ->clear_url($paths);
    $response->client = $akamai;
    return $response;
  } catch (\Exception $e) {
    return FALSE;
  }
}