File tree 1 file changed +4
-9
lines changed
1 file changed +4
-9
lines changed Original file line number Diff line number Diff line change @@ -149,12 +149,6 @@ public function restoreTreeFromNestedArray($arr, ioDoctrineMenuItem $root)
149
149
throw new sfException ('ioDoctrineMenuItemTable::restoreTreeFromNestedArray() must be called using a root node. ' );
150
150
}
151
151
152
- // remove all of the nodes from the tree
153
- $ this ->clearTree ($ root );
154
-
155
- // reestablish the root
156
- $ this ->getTree ()->createRoot ($ root );
157
-
158
152
// put the nodes back on
159
153
$ this ->restoreBranchFromNestedArray (array ('menu ' => $ root , 'children ' => $ arr ));
160
154
}
@@ -172,18 +166,19 @@ public function restoreBranchFromNestedArray($arr)
172
166
173
167
if (isset ($ arr ['children ' ]))
174
168
{
175
- foreach ($ arr ['children ' ] as $ childArr )
169
+ // for details on why we do this, see ioDoctrineMenuItem::persistFromMenuArray()
170
+ $ children = array_reverse ($ arr ['children ' ]);
171
+ foreach ($ children as $ childArr )
176
172
{
177
173
$ child = $ this ->find ($ childArr ['id ' ]);
178
- $ child ->getNode ()->insertAsLastChildOf ($ parent );
174
+ $ child ->getNode ()->moveAsFirstChildOf ($ parent );
179
175
180
176
// put the child object into the array
181
177
$ childArr ['menu ' ] = $ child ;
182
178
unset($ childArr ['id ' ]);
183
179
184
180
// recurse down and ultimately refresh the parent
185
181
$ this ->restoreBranchFromNestedArray ($ childArr );
186
- $ parent ->refresh ();
187
182
}
188
183
}
189
184
You can’t perform that action at this time.
0 commit comments