function akamai_submit_purge_request in Akamai 7.3
Submits a purge request to the CCU API.
Parameters
string $hostname: The name of the URL that contains the objects you want to purge.
array $paths: An array of paths to be purged.
Return value
object|false If the request was accepted, a response object. Otherwise, FALSE.
2 calls to akamai_submit_purge_request()
- akamai_purge_paths in ./
akamai.module - Purges a set of paths from Akamai's cache.
- akamai_submit_batch in ./
akamai.cron.inc - Submits a batch of queued purge request items to the CCU API.
File
- ./
akamai.module, line 416 - Integration with Akamai CDN CCU API.
Code
function akamai_submit_purge_request($hostname, array $paths) {
if (variable_get('akamai_disabled', FALSE)) {
watchdog('akamai', 'Request to purge paths ignored because clearing is disabled. Check module settings.');
return FALSE;
}
try {
$ccu = akamai_get_client();
$response = $ccu
->postPurgeRequest($hostname, $paths);
if (!empty($response)) {
akamai_log_purge_request($hostname, $paths, $response);
return $response;
}
} catch (GuzzleHttp\Exception\RequestException $e) {
watchdog_exception('akamai', $e);
$request = $e
->getRequest();
$request_variables = [
'@method' => $request
->getMethod(),
'@uri' => $request
->getUri(),
'@body' => (string) $request
->getBody(),
];
watchdog('akamai', 'Request: @method @uri @body', $request_variables, WATCHDOG_ERROR);
if ($e
->hasResponse()) {
$response_body = $e
->getResponse()
->getBody()
->getContents();
watchdog('akamai', 'Response: @response', [
'@response' => $response_body,
], WATCHDOG_ERROR);
}
} catch (Exception $e) {
watchdog_exception('akamai', $e);
}
return FALSE;
}