mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
updating XML class, fixes #3696
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6194 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
698af0115c
commit
194ab8364a
1 changed files with 6 additions and 4 deletions
|
@ -112,8 +112,7 @@ class XMLNode extends Object {
|
||||||
* @return array Properties from object
|
* @return array Properties from object
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function __objectToNode($object) {
|
function __objectToNode($object, $key = false) {
|
||||||
|
|
||||||
if (is_array($object)) {
|
if (is_array($object)) {
|
||||||
$objects = array();
|
$objects = array();
|
||||||
foreach ($object as $obj) {
|
foreach ($object as $obj) {
|
||||||
|
@ -124,13 +123,16 @@ class XMLNode extends Object {
|
||||||
|
|
||||||
if (isset($object->_name_) && !empty($object->_name_)) {
|
if (isset($object->_name_) && !empty($object->_name_)) {
|
||||||
$name = $object->_name_;
|
$name = $object->_name_;
|
||||||
|
} elseif ($key) {
|
||||||
|
$name = $key;
|
||||||
} elseif (isset($object->name) && $object->name != null) {
|
} elseif (isset($object->name) && $object->name != null) {
|
||||||
$name = $object->name;
|
$name = $object->name;
|
||||||
} else {
|
} else {
|
||||||
$name = get_class($object);
|
$name = get_class($object);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($name != strtolower($name)) {
|
if ($name != strtolower($name)) {
|
||||||
$name = Inflector::underscore($name);
|
$name = Inflector::slug(Inflector::underscore($name));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_object($object)) {
|
if (is_object($object)) {
|
||||||
|
@ -152,7 +154,7 @@ class XMLNode extends Object {
|
||||||
unset($attributes[$key]);
|
unset($attributes[$key]);
|
||||||
}
|
}
|
||||||
} elseif (is_object($val)) {
|
} elseif (is_object($val)) {
|
||||||
$children[] = $this->__objectToNode($val);
|
$children[] = $this->__objectToNode($val, $key);
|
||||||
unset($attributes[$key]);
|
unset($attributes[$key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue