Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/lib/zend/Zend/Service/WindowsAzure/Storage/DynamicTableEntity.php
Go to the documentation of this file.
00001 <?php
00027 require_once 'Zend/Service/WindowsAzure/Exception.php';
00028 
00032 require_once 'Zend/Service/WindowsAzure/Storage/TableEntity.php';
00033 
00034 
00042 class Zend_Service_WindowsAzure_Storage_DynamicTableEntity extends Zend_Service_WindowsAzure_Storage_TableEntity
00043 {   
00049     protected $_dynamicProperties = array();
00050     
00057     public function __set($name, $value) {      
00058         $this->setAzureProperty($name, $value, null);
00059     }
00060 
00066     public function __get($name) {
00067         return $this->getAzureProperty($name);
00068     }
00069     
00078     public function setAzureProperty($name, $value = '', $type = null)
00079     {
00080         if (strtolower($name) == 'partitionkey') {
00081             $this->setPartitionKey($value);
00082         } else if (strtolower($name) == 'rowkey') {
00083             $this->setRowKey($value);
00084         } else if (strtolower($name) == 'etag') {
00085             $this->setEtag($value);
00086         } else {
00087             if (!array_key_exists(strtolower($name), $this->_dynamicProperties)) {
00088                 // Determine type?
00089                 if (is_null($type)) {
00090                     $type = 'Edm.String';
00091                     if (is_int($value)) {
00092                         $type = 'Edm.Int32';
00093                     } else if (is_float($value)) {
00094                         $type = 'Edm.Double';
00095                     } else if (is_bool($value)) {
00096                         $type = 'Edm.Boolean';
00097                     }
00098                 }
00099                 
00100                 // Set dynamic property
00101                 $this->_dynamicProperties[strtolower($name)] = (object)array(
00102                         'Name'  => $name,
00103                         'Type'  => $type,
00104                         'Value' => $value,
00105                     );
00106             }
00107     
00108             $this->_dynamicProperties[strtolower($name)]->Value = $value;
00109         }
00110         return $this;
00111     }
00112     
00120     public function setAzurePropertyType($name, $type = 'Edm.String')
00121     {
00122         if (!array_key_exists(strtolower($name), $this->_dynamicProperties)) {
00123             $this->setAzureProperty($name, '', $type);            
00124         } else {
00125             $this->_dynamicProperties[strtolower($name)]->Type = $type;   
00126         }
00127         return $this;
00128     }
00129     
00138     public function getAzureProperty($name)
00139     {
00140         if (strtolower($name) == 'partitionkey') {
00141             return $this->getPartitionKey();
00142         }
00143         if (strtolower($name) == 'rowkey') {
00144             return $this->getRowKey();
00145         }
00146         if (strtolower($name) == 'etag') {
00147             return $this->getEtag();
00148         }
00149 
00150         if (!array_key_exists(strtolower($name), $this->_dynamicProperties)) {
00151             $this->setAzureProperty($name);            
00152         }
00153 
00154         return $this->_dynamicProperties[strtolower($name)]->Value;
00155     }
00156     
00163     public function getAzurePropertyType($name)
00164     {
00165         if (!array_key_exists(strtolower($name), $this->_dynamicProperties)) {
00166             $this->setAzureProperty($name, '', $type);            
00167         }
00168         
00169         return $this->_dynamicProperties[strtolower($name)]->Type;
00170     }
00171     
00177     public function getAzureValues()
00178     {
00179         return array_merge(array_values($this->_dynamicProperties), parent::getAzureValues());
00180     }
00181     
00189     public function setAzureValues($values = array(), $throwOnError = false)
00190     {
00191         // Set parent values
00192         parent::setAzureValues($values, false);
00193         
00194         // Set current values
00195         foreach ($values as $key => $value) 
00196         {
00197             $this->$key = $value;
00198         }
00199     }
00200 }
 All Data Structures Namespaces Files Functions Variables Enumerations