13 * to license@zend.com so we can send you a copy immediately. |
13 * to license@zend.com so we can send you a copy immediately. |
14 * |
14 * |
15 * @category Zend |
15 * @category Zend |
16 * @package Zend_Service_WindowsAzure |
16 * @package Zend_Service_WindowsAzure |
17 * @subpackage Storage |
17 * @subpackage Storage |
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
18 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
20 * @version $Id: DynamicTableEntity.php 23167 2010-10-19 17:53:31Z mabe $ |
20 * @version $Id: DynamicTableEntity.php 24593 2012-01-05 20:35:02Z matthew $ |
21 */ |
21 */ |
22 |
|
23 |
|
24 /** |
|
25 * @see Zend_Service_WindowsAzure_Exception |
|
26 */ |
|
27 require_once 'Zend/Service/WindowsAzure/Exception.php'; |
|
28 |
22 |
29 /** |
23 /** |
30 * @see Zend_Service_WindowsAzure_Storage_TableEntity |
24 * @see Zend_Service_WindowsAzure_Storage_TableEntity |
31 */ |
25 */ |
32 require_once 'Zend/Service/WindowsAzure/Storage/TableEntity.php'; |
26 require_once 'Zend/Service/WindowsAzure/Storage/TableEntity.php'; |
33 |
27 |
34 |
|
35 /** |
28 /** |
36 * @category Zend |
29 * @category Zend |
37 * @package Zend_Service_WindowsAzure |
30 * @package Zend_Service_WindowsAzure |
38 * @subpackage Storage |
31 * @subpackage Storage |
39 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
32 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
40 * @license http://framework.zend.com/license/new-bsd New BSD License |
33 * @license http://framework.zend.com/license/new-bsd New BSD License |
41 */ |
34 */ |
42 class Zend_Service_WindowsAzure_Storage_DynamicTableEntity extends Zend_Service_WindowsAzure_Storage_TableEntity |
35 class Zend_Service_WindowsAzure_Storage_DynamicTableEntity extends Zend_Service_WindowsAzure_Storage_TableEntity |
43 { |
36 { |
44 /** |
37 /** |
84 } else if (strtolower($name) == 'etag') { |
77 } else if (strtolower($name) == 'etag') { |
85 $this->setEtag($value); |
78 $this->setEtag($value); |
86 } else { |
79 } else { |
87 if (!array_key_exists(strtolower($name), $this->_dynamicProperties)) { |
80 if (!array_key_exists(strtolower($name), $this->_dynamicProperties)) { |
88 // Determine type? |
81 // Determine type? |
89 if ($type === null) { |
82 if (is_null($type)) { |
90 $type = 'Edm.String'; |
83 $type = 'Edm.String'; |
91 if (is_int($value)) { |
84 if (is_int($value)) { |
92 $type = 'Edm.Int32'; |
85 $type = 'Edm.Int32'; |
93 } else if (is_float($value)) { |
86 } else if (is_float($value)) { |
94 $type = 'Edm.Double'; |
87 $type = 'Edm.Double'; |
95 } else if (is_bool($value)) { |
88 } else if (is_bool($value)) { |
96 $type = 'Edm.Boolean'; |
89 $type = 'Edm.Boolean'; |
|
90 } else if ($value instanceof DateTime || $this->_convertToDateTime($value) !== false) { |
|
91 if (!$value instanceof DateTime) { |
|
92 $value = $this->_convertToDateTime($value); |
|
93 } |
|
94 $type = 'Edm.DateTime'; |
97 } |
95 } |
98 } |
96 } |
99 |
97 |
100 // Set dynamic property |
98 // Set dynamic property |
101 $this->_dynamicProperties[strtolower($name)] = (object)array( |
99 $this->_dynamicProperties[strtolower($name)] = (object)array( |
102 'Name' => $name, |
100 'Name' => $name, |
103 'Type' => $type, |
101 'Type' => $type, |
104 'Value' => $value, |
102 'Value' => $value, |
105 ); |
103 ); |
106 } |
104 } |
107 |
105 |
|
106 // Set type? |
|
107 if (!is_null($type)) { |
|
108 $this->_dynamicProperties[strtolower($name)]->Type = $type; |
|
109 |
|
110 // Try to convert the type |
|
111 if ($type == 'Edm.Int32' || $type == 'Edm.Int64') { |
|
112 $value = intval($value); |
|
113 } else if ($type == 'Edm.Double') { |
|
114 $value = floatval($value); |
|
115 } else if ($type == 'Edm.Boolean') { |
|
116 if (!is_bool($value)) { |
|
117 $value = strtolower($value) == 'true'; |
|
118 } |
|
119 } else if ($type == 'Edm.DateTime') { |
|
120 if (!$value instanceof DateTime) { |
|
121 $value = $this->_convertToDateTime($value); |
|
122 } |
|
123 } |
|
124 } |
|
125 |
|
126 // Set value |
108 $this->_dynamicProperties[strtolower($name)]->Value = $value; |
127 $this->_dynamicProperties[strtolower($name)]->Value = $value; |
109 } |
128 } |
110 return $this; |
129 return $this; |
111 } |
130 } |
112 |
131 |