diff options
author | wei <> | 2006-06-12 03:10:47 +0000 |
---|---|---|
committer | wei <> | 2006-06-12 03:10:47 +0000 |
commit | 1c6f1f79d011579a158e87459040075331b636b7 (patch) | |
tree | 75236e04a5e2aaf9685b34ed7bed0f82e591bbb4 /framework/DataAccess/SQLMap/DataMapper/TPropertyAccess.php | |
parent | f30c38fcc9d6cdfa7aafa5078a58645192c11974 (diff) |
Minor updates.
Diffstat (limited to 'framework/DataAccess/SQLMap/DataMapper/TPropertyAccess.php')
-rw-r--r-- | framework/DataAccess/SQLMap/DataMapper/TPropertyAccess.php | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/framework/DataAccess/SQLMap/DataMapper/TPropertyAccess.php b/framework/DataAccess/SQLMap/DataMapper/TPropertyAccess.php index 8680601e..4bbe2cb5 100644 --- a/framework/DataAccess/SQLMap/DataMapper/TPropertyAccess.php +++ b/framework/DataAccess/SQLMap/DataMapper/TPropertyAccess.php @@ -39,7 +39,7 @@ class TPropertyAccess */
public static function get($object,$path)
{
- if(!is_array($object) && !is_object($object))
+ if(!is_array($object) || !is_object($object))
return $object;
$properties = explode('.', $path);
foreach($properties as $prop)
@@ -67,6 +67,34 @@ class TPropertyAccess return $object;
}
+ public static function has($object, $path)
+ {
+ if(!is_array($object) || !is_object($object))
+ return false;
+ $properties = explode('.', $path);
+ foreach($properties as $prop)
+ {
+ if(is_array($object) || $object instanceof ArrayAccess)
+ {
+ if(isset($object[$prop]))
+ $object = $object[$prop];
+ else
+ return false;
+ }
+ else if(is_object($object))
+ {
+ $getter = 'get'.$prop;
+ if(is_callable(array($object,$getter)))
+ $object = $object->{$getter}();
+ else if(in_array($prop, array_keys(get_object_vars($object))))
+ $object = $object->{$prop};
+ return false;
+ }
+ else
+ return false;
+ }
+ return true;
+ }
public static function set($object, $path, $value)
{
|