mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
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:
parent
29436a0ec5
commit
ff2870fb41
1 changed files with 7 additions and 4 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue