You are here

public function Ccu2Client::getPurgeBody in Akamai 7.3

Implements CcuClientInterface::getPurgeBody().

Overrides CcuClientInterface::getPurgeBody

File

src/Ccu2Client.php, line 66
Contains the Drupal\akamai\Ccu2Client class.

Class

Ccu2Client

Namespace

Drupal\akamai

Code

public function getPurgeBody($hostname, array $paths) {

  // Strip whitespace from paths and ensure each path begins with a '/'.
  // CCU API v2 requires absolute URLs, so prepend hostname and schemes.
  foreach ($paths as $key => $path) {
    $path = rtrim(preg_match("/^\\//", $path) ? $path : "/{$path}");
    $paths[$key] = 'http://' . $hostname . $path;
    $paths[] = 'https://' . $hostname . $path;
  }
  $purge_body = array(
    'action' => $this->operation,
    'objects' => array_unique($paths),
    'domain' => $this->network,
  );
  return json_encode($purge_body);
}