Skip to content

Commit 56dd9b1

Browse files
author
Jamie Hannaford
committed
Merge pull request rackspace#593 from jamiehannaford/cdn-fix
Fix CDN container population
2 parents 5487d5a + 7cdca13 commit 56dd9b1

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

doc/services/object-store/cdn.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ Once a container has been CDN-enabled, you can retrieve it like so:
7171
7272
$cdnContainer = $cdnService->cdnContainer('{containerName}');
7373
74+
If you already have a container object and want to avoid instantiating a new service, you can also do:
75+
76+
.. code-block:: php
77+
78+
$cdnContainer = $container->getCdn();
79+
7480
7581
Retrieve the SSL URL of a CDN container
7682
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

lib/OpenCloud/ObjectStore/CDNService.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,19 @@ public function cdnContainer($data)
5454
{
5555
$container = new CDNContainer($this, $data);
5656

57-
$metadata = new ContainerMetadata();
58-
$metadata->setArray(array(
59-
'Streaming-Uri' => $data->cdn_streaming_uri,
60-
'Ios-Uri' => $data->cdn_ios_uri,
61-
'Ssl-Uri' => $data->cdn_ssl_uri,
62-
'Enabled' => $data->cdn_enabled,
63-
'Ttl' => $data->ttl,
64-
'Log-Retention' => $data->log_retention,
65-
'Uri' => $data->cdn_uri,
66-
));
67-
68-
$container->setMetadata($metadata);
57+
if (is_object($data)) {
58+
$metadata = new ContainerMetadata();
59+
$metadata->setArray(array(
60+
'Streaming-Uri' => $data->cdn_streaming_uri,
61+
'Ios-Uri' => $data->cdn_ios_uri,
62+
'Ssl-Uri' => $data->cdn_ssl_uri,
63+
'Enabled' => $data->cdn_enabled,
64+
'Ttl' => $data->ttl,
65+
'Log-Retention' => $data->log_retention,
66+
'Uri' => $data->cdn_uri,
67+
));
68+
$container->setMetadata($metadata);
69+
}
6970

7071
return $container;
7172
}

0 commit comments

Comments
 (0)