summaryrefslogtreecommitdiff
path: root/framework/Data/TDataFieldAccessor.php
diff options
context:
space:
mode:
authorxue <>2006-03-13 02:38:47 +0000
committerxue <>2006-03-13 02:38:47 +0000
commit7770c298450237e092d6d801fd547609ba2db230 (patch)
treeddc92889b2f10256f59a4024f5bed5cc01d73bdf /framework/Data/TDataFieldAccessor.php
parent6ae6538555d45b3e947f5ce0d948d9b88d95364a (diff)
TDataFieldAccessor can access public member variables now. Added implementation to cope with low PHP versions.
Diffstat (limited to 'framework/Data/TDataFieldAccessor.php')
-rw-r--r--framework/Data/TDataFieldAccessor.php16
1 files changed, 11 insertions, 5 deletions
diff --git a/framework/Data/TDataFieldAccessor.php b/framework/Data/TDataFieldAccessor.php
index e0c87add..a28b9d1f 100644
--- a/framework/Data/TDataFieldAccessor.php
+++ b/framework/Data/TDataFieldAccessor.php
@@ -57,7 +57,12 @@ class TDataFieldAccessor
else if(is_object($data))
{
if(strpos($field,'.')===false) // simple field
- return call_user_func(array($data,'get'.$field));
+ {
+ if(property_exists($data,$field))
+ return $data->{$field};
+ else
+ return call_user_func(array($data,'get'.$field));
+ }
else // field in the format of xxx.yyy.zzz
{
$object=$data;
@@ -82,11 +87,12 @@ class TDataFieldAccessor
{
if(strpos($field,'.')===false) // simple field
{
- $getter='get'.$field;
- if(is_callable(array($data,$getter)))
- return call_user_func(array($data,$getter));
- else if(in_array($field, array_keys(get_object_vars($data))))
+ if(property_exists($data,$field))
return $data->{$field};
+ else if(is_callable(array($data,'get'.$field)))
+ return call_user_func(array($data,'get'.$field));
+ else
+ throw new TInvalidDataValueException('datafieldaccessor_datafield_invalid',$field);
}
else // field in the format of xxx.yyy.zzz
{