Adding model name mapping property to mapped objects in Set::map()

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3584 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2006-09-28 20:26:54 +00:00
parent 29436a0ec5
commit ff2870fb41

View file

@ -97,14 +97,14 @@ class Set extends Object {
} elseif (is_a($this, 'set') || is_a($this, 'Set')) {
$val = $this->get();
}
if (empty($val) || $val == null) {
return null;
}
return Set::__map($val, $class);
}
function __map($value, $class) {
function __map($value, $class, $identity = null) {
if (!empty($value) && Set::numeric(array_keys($value))) {
$ret = array();
foreach ($value as $key => $val) {
@ -112,6 +112,9 @@ class Set extends Object {
}
} else {
$ret = new $class;
if ($identity != null) {
$ret->__identity__ = $identity;
}
}
if (empty($value)) {
@ -123,9 +126,9 @@ class Set extends Object {
if (!is_numeric($key) && strlen($key) > 1) {
if ($key{0} == strtoupper($key{0}) && $key{1} == strtolower($key{1})) {
if ($key == $keys[0]) {
$ret = Set::__map($val, $class);
$ret = Set::__map($val, $class, $key);
} else {
$ret->{$key} = Set::__map($val, $class);
$ret->{$key} = Set::__map($val, $class, $key);
}
} else {
$ret->{$key} = $val;