@@ -6,18 +6,15 @@ class NestedSet_Model_Output
66 * Convert a tree array (with depth) into a hierarchical array.
77 *
88 * @param $model|NestedSet_Model Nested set model
9- * @param $tree |array Array with depth value.
9+ * @param $nodes |array Array with depth value.
1010 *
1111 * @return array
1212 */
13- public function toArray (NestedSet_Model $ nestedset , $ tree = null )
13+ public function toArray (NestedSet_Model $ nestedset , array $ nodes = array () )
1414 {
15- if (empty ($ tree ) || ! is_array ( $ tree )) {
15+ if (empty ($ nodes )) {
1616 $ nodes = $ nestedset ->getAll ();
1717 }
18- else {
19- $ nodes = $ tree ;
20- }
2118
2219 $ result = array ();
2320 $ stackLevel = 0 ;
@@ -64,18 +61,15 @@ public function toArray(NestedSet_Model $nestedset, $tree = null)
6461 * Convert a tree array (with depth) into a hierarchical XML string.
6562 *
6663 * @param $model|NestedSet_Model Nested set model
67- * @param $tree |array Array with depth value.
64+ * @param $nodes |array Array with depth value.
6865 *
6966 * @return string
7067 */
71- public function toXml (NestedSet_Model $ nestedset , $ tree = null )
68+ public function toXml (NestedSet_Model $ nestedset , array $ nodes = array () )
7269 {
73- if (empty ($ tree ) || ! is_array ( $ tree )) {
70+ if (empty ($ nodes )) {
7471 $ nodes = $ nestedset ->getAll ();
7572 }
76- else {
77- $ nodes = $ tree ;
78- }
7973
8074 $ xml = new DomDocument ('1.0 ' );
8175 $ xml ->preserveWhiteSpace = false ;
@@ -119,13 +113,13 @@ public function toXml(NestedSet_Model $nestedset, $tree = null)
119113 /**
120114 * Return nested set as JSON
121115 *
122- * @params $tree |array Original 'flat' nested tree
116+ * @params $nodes |array Original 'flat' nested tree
123117 *
124118 * @return string
125119 */
126- public function toJson (NestedSet_Model $ nestedset , $ tree = null )
120+ public function toJson (NestedSet_Model $ nestedset , array $ nodes = array () )
127121 {
128- $ nestedArray = $ this ->toArray ($ nestedset , $ tree );
122+ $ nestedArray = $ this ->toArray ($ nestedset , $ nodes );
129123 $ result = json_encode ($ nestedArray );
130124
131125 return $ result ;
@@ -141,14 +135,11 @@ public function toJson(NestedSet_Model $nestedset, $tree = null)
141135 *
142136 * @return string
143137 */
144- public function toHtml (NestedSet_Model $ nestedset , $ tree = null , $ method = 'list ' )
138+ public function toHtml (NestedSet_Model $ nestedset , array $ nodes = array () , $ method = 'list ' )
145139 {
146- if (empty ($ tree ) || ! is_array ( $ tree )) {
140+ if (empty ($ nodes )) {
147141 $ nodes = $ nestedset ->getAll ();
148142 }
149- else {
150- $ nodes = $ tree ;
151- }
152143
153144 switch ($ method ) {
154145 case 'list ' :
0 commit comments