作者:azt3
项目:drupal-azure-blo
/**
* Creates GetHostedServicePropertiesResult from parsed response.
*
* @param array $parsed The parsed response in array representation.
*
* @return GetHostedServicePropertiesResult
*/
public static function create($parsed)
{
$result = new GetHostedServicePropertiesResult();
$properties = Utilities::tryGetValue($parsed, Resources::XTAG_HOSTED_SERVICE_PROPERTIES);
$result->_hostedService = new HostedService($parsed, $properties);
return $result;
}
作者:isrealconsultin
项目:sit
/**
* Computes canonicalized headers for headers array.
*
* @param array $headers request headers.
*
* @see Constructing the Canonicalized Headers String section at
* http://msdn.microsoft.com/en-us/library/windowsazure/dd179428.aspx
*
* @return array
*/
protected function computeCanonicalizedHeaders($headers)
{
$canonicalizedHeaders = array();
$normalizedHeaders = array();
$validPrefix = Resources::X_MS_HEADER_PREFIX;
if (is_null($normalizedHeaders)) {
return $canonicalizedHeaders;
}
foreach ($headers as $header => $value) {
// Convert header to lower case.
$header = strtolower($header);
// Retrieve all headers for the resource that begin with x-ms-,
// including the x-ms-date header.
if (Utilities::startsWith($header, $validPrefix)) {
// Unfold the string by replacing any breaking white space
// (meaning what splits the headers, which is \r\n) with a single
// space.
$value = str_replace("\r\n", ' ', $value);
// Trim any white space around the colon in the header.
$value = ltrim($value);
$header = rtrim($header);
$normalizedHeaders[$header] = $value;
}
}
// Sort the headers lexicographically by header name, in ascending order.
// Note that each header may appear only once in the string.
ksort($normalizedHeaders);
foreach ($normalizedHeaders as $key => $value) {
$canonicalizedHeaders[] = $key . ':' . $value;
}
return $canonicalizedHeaders;
}
作者:GabrielAnc
项目:azure-sdk-for-ph
/**
* Converts the current object into ordered array representation.
*
* @return array
*/
protected function toArray()
{
$arr = parent::toArray();
$order = array(Resources::XTAG_NAMESPACE, Resources::XTAG_SERVICE_NAME, Resources::XTAG_LABEL, Resources::XTAG_DESCRIPTION, Resources::XTAG_LOCATION, Resources::XTAG_AFFINITY_GROUP);
$ordered = Utilities::orderArray($arr, $order);
return $ordered;
}
作者:rdohm
项目:azure-sdk-for-ph
/**
* Creates ListBlobResult object from parsed XML response.
*
* @param array $parsedResponse XML response parsed into array.
*
* @return WindowsAzure\Blob\Models\ListBlobResult.
*/
public static function create($parsedResponse)
{
$result = new ListContainersResult();
$result->_prefix = Utilities::tryGetValue($parsedResponse, Resources::QP_PREFIX);
$result->_marker = Utilities::tryGetValue($parsedResponse, Resources::QP_MARKER);
$result->_nextMarker = Utilities::tryGetValue($parsedResponse, Resources::QP_NEXT_MARKER);
$result->_maxResults = Utilities::tryGetValue($parsedResponse, Resources::QP_MAX_RESULTS);
$result->_containers = array();
$rawContainer = array();
if (!empty($parsedResponse['Containers'])) {
$containersArray = $parsedResponse['Containers']['Container'];
$rawContainer = Utilities::getArray($containersArray);
}
foreach ($rawContainer as $value) {
$container = new Container();
$container->setName($value['Name']);
$container->setUrl($value['Url']);
$container->setMetadata(Utilities::tryGetValue($value, Resources::QP_METADATA, array()));
$properties = new ContainerProperties();
$date = $value['Properties']['Last-Modified'];
$date = Utilities::rfc1123ToDateTime($date);
$properties->setLastModified($date);
$properties->setEtag($value['Properties']['Etag']);
$container->setProperties($properties);
$result->_containers[] = $container;
}
return $result;
}
作者:GameWis
项目:azure-sdk-for-ph
/**
* Given array of MIME parts in raw string, this function converts them into MIME
* representation.
*
* @param array $bodyPartContents The MIME body parts.
*
* @return array Returns array with two elements 'headers' and 'body' which
* represents the MIME message.
*/
public function encodeMimeMultipart($bodyPartContents)
{
$count = count($bodyPartContents);
$mimeType = Resources::MULTIPART_MIXED_TYPE;
$batchGuid = Utilities::getGuid();
$batchId = sprintf('batch_%s', $batchGuid);
$contentType1 = array('content_type' => "{$mimeType}");
$changeSetGuid = Utilities::getGuid();
$changeSetId = sprintf('changeset_%s', $changeSetGuid);
$contentType2 = array('content_type' => "{$mimeType}; boundary={$changeSetId}");
$options = array('encoding' => 'binary', 'content_type' => Resources::HTTP_TYPE);
// Create changeset MIME part
$changeSet = new \Mail_mimePart();
for ($i = 0; $i < $count; $i++) {
$changeSet->addSubpart($bodyPartContents[$i], $options);
}
// Encode the changeset MIME part
$changeSetEncoded = $changeSet->encode($changeSetId);
// Create the batch MIME part
$batch = new \Mail_mimePart(Resources::EMPTY_STRING, $contentType1);
// Add changeset encoded to batch MIME part
$batch->addSubpart($changeSetEncoded['body'], $contentType2);
// Encode batch MIME part
$batchEncoded = $batch->encode($batchId);
return $batchEncoded;
}
作者:bitmovi
项目:azure-sdk-for-ph
/**
* Creates GetStorageServicePropertiesResult from parsed response.
*
* @param array $parsed The parsed response in array representation.
*
* @return GetStorageServicePropertiesResult
*/
public static function create($parsed)
{
$result = new GetStorageServicePropertiesResult();
$properties = Utilities::tryGetValue($parsed, Resources::XTAG_STORAGE_SERVICE_PROPERTIES);
$result->_storageService = new StorageService($parsed, $properties);
return $result;
}
作者:southworksco
项目:azure-sdk-for-ph
/**
* Creates WrapAccesTokenResult object from parsed XML response.
*
* @param array $response The get WRAP access token response.
*
* @return WindowsAzure\ServiceBus\Internal\WrapAccessTokenResult.
*/
public static function create($response)
{
$wrapAccessTokenResult = new self();
parse_str($response, $parsedResponse);
$wrapAccessTokenResult->setAccessToken(Utilities::tryGetValue($parsedResponse, Resources::WRAP_ACCESS_TOKEN));
$wrapAccessTokenResult->setExpiresIn(Utilities::tryGetValue($parsedResponse, Resources::WRAP_ACCESS_TOKEN_EXPIRES_IN));
return $wrapAccessTokenResult;
}
作者:bitmovi
项目:azure-sdk-for-ph
/**
* Creates GetBlobResult from getBlob call.
*
* @param array $headers The HTTP response headers.
* @param string $body The response body.
* @param array $metadata The blob metadata.
*
* @return GetBlobResult
*/
public static function create($headers, $body, $metadata)
{
$result = new GetBlobResult();
$result->setContentStream(Utilities::stringToStream($body));
$result->setProperties(BlobProperties::create($headers));
$result->setMetadata(is_null($metadata) ? array() : $metadata);
return $result;
}
作者:mat3347
项目:PF
/**
* Create InsertEntityResult object from HTTP response parts.
*
* @param string $body The HTTP response body.
* @param array $headers The HTTP response headers.
* @param IAtomReaderWriter $atomSerializer The atom reader and writer.
*
* @return \WindowsAzure\Table\Models\InsertEntityResult
*
* @static
*/
public static function create($body, $headers, $atomSerializer)
{
$result = new InsertEntityResult();
$entity = $atomSerializer->parseEntity($body);
$entity->setETag(Utilities::tryGetValue($headers, Resources::ETAG));
$result->setEntity($entity);
return $result;
}
作者:pankajadhyapa
项目:um_ne
/**
* Converts the current object into ordered array representation.
*
* @return array
*/
protected function toArray()
{
$arr = parent::toArray();
$order = array(Resources::XTAG_NAMESPACE, Resources::XTAG_NAME, Resources::XTAG_LABEL, Resources::XTAG_DESCRIPTION, Resources::XTAG_LOCATION);
Utilities::addIfNotEmpty(Resources::XTAG_NAME, $this->getName(), $arr);
$ordered = Utilities::orderArray($arr, $order);
return $ordered;
}
作者:rdohm
项目:azure-sdk-for-ph
/**
* Creates CopyBlobResult object from the response of the copy blob request.
*
* @param array $headers The HTTP response headers in array representation.
*
* @return CopyBlobResult
*/
public static function create($headers)
{
$result = new CopyBlobResult();
$headerWithLowerCaseKey = array_change_key_case($headers);
$result->setEtag($headerWithLowerCaseKey[Resources::ETAG]);
$result->setLastModified(Utilities::rfc1123ToDateTime($headerWithLowerCaseKey[Resources::LAST_MODIFIED]));
return $result;
}
作者:rdohm
项目:azure-sdk-for-ph
/**
* Creates new QueryTablesResult object
*
* @param array $headers The HTTP response headers
* @param array $entries The table entriess
*
* @return \WindowsAzure\Table\Models\QueryTablesResult
*/
public static function create($headers, $entries)
{
$result = new QueryTablesResult();
$headers = array_change_key_case($headers);
$result->setNextTableName(Utilities::tryGetValue($headers, Resources::X_MS_CONTINUATION_NEXTTABLENAME));
$result->setTables($entries);
return $result;
}
作者:skinnar
项目:FTL-
/**
* Creates SetBlobMetadataResult from response headers.
*
* @param array $headers response headers
*
* @return SetBlobMetadataResult
*/
public static function create($headers)
{
$result = new SetBlobMetadataResult();
$date = $headers[Resources::LAST_MODIFIED];
$result->setLastModified(Utilities::rfc1123ToDateTime($date));
$result->setETag($headers[Resources::ETAG]);
return $result;
}
作者:GabrielAnc
项目:azure-sdk-for-ph
/**
* Creates new ListStorageServicesResult from parsed response body.
*
* @param array $parsed The parsed response body.
*
* @return ListStorageServicesResult
*/
public static function create($parsed)
{
$result = new ListStorageServicesResult();
$rowStorageServices = Utilities::tryGetArray(Resources::XTAG_STORAGE_SERVICE, $parsed);
foreach ($rowStorageServices as $rowStorageService) {
$result->_storageServices[] = new StorageService($rowStorageService);
}
return $result;
}
作者:rdohm
项目:azure-sdk-for-ph
/**
* Creates new GetStorageServiceKeysResult object from parsed response.
*
* @param array $parsed The HTTP parsed response into array representation.
*
* @return GetStorageServiceKeysResult
*/
public static function create($parsed)
{
$result = new GetStorageServiceKeysResult();
$keys = Utilities::tryGetValue($parsed, Resources::XTAG_STORAGE_SERVICE_KEYS);
$result->_url = Utilities::tryGetValue($parsed, Resources::XTAG_URL);
$result->_primary = Utilities::tryGetValue($keys, Resources::XTAG_PRIMARY);
$result->_secondary = Utilities::tryGetValue($keys, Resources::XTAG_SECONDARY);
return $result;
}
作者:rdohm
项目:azure-sdk-for-ph
/**
* Creates GetBlobMetadataResult from response headers.
*
* @param array $headers The HTTP response headers.
* @param array $metadata The blob metadata array.
*
* @return GetBlobMetadataResult
*/
public static function create($headers, $metadata)
{
$result = new GetBlobMetadataResult();
$date = $headers[Resources::LAST_MODIFIED];
$result->setLastModified(Utilities::rfc1123ToDateTime($date));
$result->setEtag($headers[Resources::ETAG]);
$result->setMetadata(is_null($metadata) ? array() : $metadata);
return $result;
}
作者:mat3347
项目:PF
/**
* Creates a new Role from parsed response body.
*
* @param array $parsed The parsed response body in array representation.
*
* @return Role
*/
public static function create($parsed)
{
$role = new Role();
$roleName = Utilities::tryGetValue($parsed, Resources::XTAG_ROLE_NAME);
$osVersion = Utilities::tryGetValue($parsed, Resources::XTAG_OS_VERSION);
$role->setOsVersion($osVersion);
$role->setRoleName($roleName);
return $role;
}
作者:bitmovi
项目:azure-sdk-for-ph
/**
* Creates CopyBlobResult object from the response of the copy blob request.
*
* @param array $headers The HTTP response headers in array representation.
*
* @return CopyBlobResult
*/
public static function create($headers)
{
$result = new CopyBlobResult();
$result->setETag(Utilities::tryGetValueInsensitive(Resources::ETAG, $headers));
if (Utilities::arrayKeyExistsInsensitive(Resources::LAST_MODIFIED, $headers)) {
$lastModified = Utilities::tryGetValueInsensitive(Resources::LAST_MODIFIED, $headers);
$result->setLastModified(Utilities::rfc1123ToDateTime($lastModified));
}
return $result;
}
作者:southworksco
项目:azure-sdk-for-ph
/**
* Creates new ListAffinityGroupsResult from parsed response body.
*
* @param array $parsed The parsed response body.
*
* @return ListAffinityGroupsResult
*/
public static function create($parsed)
{
$result = new self();
$result->_affinityGroups = array();
$entries = Utilities::tryGetArray(Resources::XTAG_AFFINITY_GROUP, $parsed);
foreach ($entries as $value) {
$result->_affinityGroups[] = new AffinityGroup($value);
}
return $result;
}
作者:bitmovi
项目:azure-sdk-for-ph
/**
* @covers WindowsAzure\Blob\Models\CreateBlobPagesResult::setLastModified
* @covers WindowsAzure\Blob\Models\CreateBlobPagesResult::getLastModified
*/
public function testSetLastModified()
{
// Setup
$expected = Utilities::rfc1123ToDateTime('Sun, 25 Sep 2011 19:42:18 GMT');
$options = new CreateBlobPagesResult();
$options->setLastModified($expected);
// Test
$options->setLastModified($expected);
// Assert
$this->assertEquals($expected, $options->getLastModified());
}