function __construct($value) { parent::__construct($value); $this->members = array(); foreach ($value["A membre"] as $memberArray) { $member = new RemoteObject($memberArray); array_push($this->members, $member); } }
/** * Create a new RemoteObject from HTTP headers. * * This is used to create objects from GET and HEAD requests, which * return all of the metadata inside of the headers. * * @param string $name * The name of the object. * @param array $headers * An associative array of HTTP headers in the exact format * documented by OpenStack's API docs. * @param string $token * The current auth token (used for issuing subsequent requests). * @param string $url * The URL to the object in the object storage. Used for issuing * subsequent requests. * @param string $cdnUrl * The URL to the CDN version of the object. Used for issuing * subsequent requests. If this is set, this object may use * CDN to make subsequent requests. It may also return the * CDN URL when requested. * @param string $cdnSslUrl * The URL to the SSL-protected CDN version of the object. * * @retval HPCloud::Storage::ObjectStorage::RemoteObject * @return \HPCloud\Storage\ObjectStorage\RemoteObject * A new RemoteObject. */ public static function newFromHeaders($name, $headers, $token, $url, $cdnUrl = NULL, $cdnSslUrl = NULL) { $object = new RemoteObject($name); //$object->allHeaders = $headers; $object->setHeaders($headers); //throw new \Exception(print_r($headers, TRUE)); // Fix inconsistant header. if (isset($headers['ETag'])) { $headers['Etag'] = $headers['ETag']; } $object->setContentType($headers['Content-Type']); $object->contentLength = empty($headers['Content-Length']) ? 0 : (int) $headers['Content-Length']; $object->etag = (string) $headers['Etag']; // ETag is now Etag. $object->lastModified = strtotime($headers['Last-Modified']); // Set the metadata, too. $object->setMetadata(Container::extractHeaderAttributes($headers)); // If content encoding and disposition exist, set them on the // object. if (!empty($headers['Content-Disposition'])) { $object->setDisposition($headers['Content-Disposition']); } if (!empty($headers['Content-Encoding'])) { $object->setEncoding($headers['Content-Encoding']); } $object->token = $token; $object->url = $url; $object->cdnUrl = $cdnUrl; $object->cdnSslUrl = $cdnSslUrl; return $object; }
/** * Perform the HTTP query for a list of objects and de-serialize the * results. */ protected function objectQuery($params = array(), $limit = NULL, $marker = NULL) { if (isset($limit)) { $params['limit'] = (int) $limit; if (!empty($marker)) { $params['marker'] = (string) $marker; } } // We always want JSON. $params['format'] = 'json'; $query = http_build_query($params); $query = str_replace('%2F', '/', $query); $url = $this->url . '?' . $query; $client = \HPCloud\Transport::instance(); $headers = array('X-Auth-Token' => $this->token); $response = $client->doRequest($url, 'GET', $headers); // The only codes that should be returned are 200 and the ones // already thrown by doRequest. if ($response->status() != 200) { throw new \HPCloud\Exception('An unknown exception occurred while processing the request.'); } $responseContent = $response->content(); $json = json_decode($responseContent, TRUE); // Turn the array into a list of RemoteObject instances. $list = array(); foreach ($json as $item) { if (!empty($item['subdir'])) { $list[] = new Subdir($item['subdir'], $params['delimiter']); } elseif (empty($item['name'])) { throw new \HPCloud\Exception('Unexpected entity returned.'); } else { //$url = $this->url . '/' . rawurlencode($item['name']); $url = self::objectUrl($this->url, $item['name']); $list[] = RemoteObject::newFromJSON($item, $this->token, $url); } } return $list; }
function __construct($dataArray) { parent::__construct($dataArray); $this->BTs = array(); $this->done = false; }