summaryrefslogtreecommitdiff
path: root/framework/DataAccess/SQLMap
diff options
context:
space:
mode:
Diffstat (limited to 'framework/DataAccess/SQLMap')
-rw-r--r--framework/DataAccess/SQLMap/Configuration/TConfigDeserialize.php21
-rw-r--r--framework/DataAccess/SQLMap/DataMapper/TPropertyAccess.php30
2 files changed, 43 insertions, 8 deletions
diff --git a/framework/DataAccess/SQLMap/Configuration/TConfigDeserialize.php b/framework/DataAccess/SQLMap/Configuration/TConfigDeserialize.php
index 9a44d1ec..ee8f1744 100644
--- a/framework/DataAccess/SQLMap/Configuration/TConfigDeserialize.php
+++ b/framework/DataAccess/SQLMap/Configuration/TConfigDeserialize.php
@@ -111,6 +111,7 @@ class TConfigDeserialize
$property->initialize($sqlMap, $resultMap);
$resultMap->addResultProperty($property);
}
+
$discriminator = null;
if(isset($node->discriminator))
{
@@ -118,18 +119,24 @@ class TConfigDeserialize
$this->loadConfiguration($discriminator, $node->discriminator, $file);
$discriminator->initMapping($sqlMap, $resultMap);
}
+
+
+
foreach($node->subMap as $subMapNode)
{
- if(is_null($discriminator))
- throw new TSqlMapConfigurationException(
- 'sqlmap_undefined_discriminator', $resultMap->getID(), $file);
- $subMap = new TSubMap;
- $this->loadConfiguration($subMap, $subMapNode, $file);
- $discriminator->add($subMap);
+ if(isset($subMapNode['value']))
+ {
+ if(is_null($discriminator))
+ throw new TSqlMapConfigurationException(
+ 'sqlmap_undefined_discriminator', $resultMap->getID(), $file);
+
+ $subMap = new TSubMap;
+ $this->loadConfiguration($subMap, $subMapNode, $file);
+ $discriminator->add($subMap);
+ }
}
if(!is_null($discriminator))
$resultMap->setDiscriminator($discriminator);
-
return $resultMap;
}
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)
{