generate_invalidation_xml ( $caller_reference, $opt )

Generates the Invalidation Config XML used in create_invalidation().

Access

public

Parameters

Parameter

Type

Required

Description

$caller_reference

string

Required

A unique identifier for the request. A timestamp-appended string is recommended.

$opt

array

Optional

An associative array of parameters that can have the following keys:

  • Paths - string|array - Optional - One or more paths to set for invalidation. Pass a string for a single value, or an indexed array for multiple values.

Returns

Type

Description

string

An XML document to be used as the Invalidation configuration.

Related Methods

Source

Method defined in services/cloudfront.class.php | Toggle source view (23 lines) | View on GitHub

public function generate_invalidation_xml($caller_reference, $opt = null)
{
    // Default, empty XML
    $xml = simplexml_load_string(sprintf($this->base_xml, 'InvalidationBatch'));

    // CallerReference
    $xml->addChild('CallerReference', $caller_reference);

    // Paths
    if (isset($opt['Paths']))
    {
        $paths = is_array($opt['Paths']) ? $opt['Paths'] : array($opt['Paths']);

        foreach ($paths as $path)
        {
            $path = str_replace('%2F', '/', rawurlencode($path));
            $path = (substr($path, 0, 1) === '/') ? $path : ('/' . $path);
            $xml->addChild('Path', $path);
        }
    }

    return $xml->asXML();
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback