当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Service_WindowsAzure_Storage_TableEntity::getEtag方法代码示例

本文整理汇总了PHP中Zend_Service_WindowsAzure_Storage_TableEntity::getEtag方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Service_WindowsAzure_Storage_TableEntity::getEtag方法的具体用法?PHP Zend_Service_WindowsAzure_Storage_TableEntity::getEtag怎么用?PHP Zend_Service_WindowsAzure_Storage_TableEntity::getEtag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Service_WindowsAzure_Storage_TableEntity的用法示例。


在下文中一共展示了Zend_Service_WindowsAzure_Storage_TableEntity::getEtag方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _changeEntity

 /**
  * Update entity / merge entity
  * 
  * @param string                              $httpVerb    HTTP verb to use (PUT = update, MERGE = merge)
  * @param string                              $tableName   Table name
  * @param Zend_Service_WindowsAzure_Storage_TableEntity $entity      Entity to update
  * @param boolean                             $verifyEtag  Verify etag of the entity (used for concurrency)
  * @throws Zend_Service_WindowsAzure_Exception
  */
 protected function _changeEntity($httpVerb = Zend_Http_Client::PUT, $tableName = '', Zend_Service_WindowsAzure_Storage_TableEntity $entity = null, $verifyEtag = false)
 {
     if ($tableName === '') {
         throw new Zend_Service_WindowsAzure_Exception('Table name is not specified.');
     }
     if ($entity === null) {
         throw new Zend_Service_WindowsAzure_Exception('Entity is not specified.');
     }
     // Add header information
     $headers = array();
     $headers['Content-Type'] = 'application/atom+xml';
     $headers['Content-Length'] = 0;
     if (!$verifyEtag) {
         $headers['If-Match'] = '*';
     } else {
         $headers['If-Match'] = $entity->getEtag();
     }
     // Generate request body
     $requestBody = '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
                     <entry xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
                       <title />
                       <updated>{tpl:Updated}</updated>
                       <author>
                         <name />
                       </author>
                       <id />
                       <content type="application/xml">
                         <m:properties>
                           {tpl:Properties}
                         </m:properties>
                       </content>
                     </entry>';
     // Attempt to get timestamp from entity
     $timestamp = $entity->getTimestamp();
     if ($timestamp == Zend_Service_WindowsAzure_Storage_TableEntity::DEFAULT_TIMESTAMP) {
         $timestamp = $this->isoDate();
     }
     $requestBody = $this->_fillTemplate($requestBody, array('Updated' => $timestamp, 'Properties' => $this->_generateAzureRepresentation($entity)));
     // Add header information
     $headers = array();
     $headers['Content-Type'] = 'application/atom+xml';
     if (!$verifyEtag) {
         $headers['If-Match'] = '*';
     } else {
         $headers['If-Match'] = $entity->getEtag();
     }
     // Perform request
     $response = null;
     if ($this->isInBatch()) {
         $this->getCurrentBatch()->enlistOperation($tableName . '(PartitionKey=\'' . $entity->getPartitionKey() . '\',RowKey=\'' . $entity->getRowKey() . '\')', '', $httpVerb, $headers, true, $requestBody);
         return null;
     } else {
         $response = $this->_performRequest($tableName . '(PartitionKey=\'' . $entity->getPartitionKey() . '\',RowKey=\'' . $entity->getRowKey() . '\')', '', $httpVerb, $headers, true, $requestBody);
     }
     if ($response->isSuccessful()) {
         // Update properties
         $entity->setEtag($response->getHeader('Etag'));
         $entity->setTimestamp($response->getHeader('Last-modified'));
         return $entity;
     } else {
         throw new Zend_Service_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
     }
 }
开发者ID:hirentricore,项目名称:devmagento,代码行数:72,代码来源:Table.php


注:本文中的Zend_Service_WindowsAzure_Storage_TableEntity::getEtag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。