Skip to content

Commit bcfc3f7

Browse files
committed
Reworking reordering so it doesn't clear the tree before reordering. Test still passes afterwards :)
1 parent b1c4f41 commit bcfc3f7

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

lib/model/doctrine/PluginioDoctrineMenuItemTable.class.php

+4-9
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,6 @@ public function restoreTreeFromNestedArray($arr, ioDoctrineMenuItem $root)
149149
throw new sfException('ioDoctrineMenuItemTable::restoreTreeFromNestedArray() must be called using a root node.');
150150
}
151151

152-
// remove all of the nodes from the tree
153-
$this->clearTree($root);
154-
155-
// reestablish the root
156-
$this->getTree()->createRoot($root);
157-
158152
// put the nodes back on
159153
$this->restoreBranchFromNestedArray(array('menu' => $root, 'children' => $arr));
160154
}
@@ -172,18 +166,19 @@ public function restoreBranchFromNestedArray($arr)
172166

173167
if (isset($arr['children']))
174168
{
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)
176172
{
177173
$child = $this->find($childArr['id']);
178-
$child->getNode()->insertAsLastChildOf($parent);
174+
$child->getNode()->moveAsFirstChildOf($parent);
179175

180176
// put the child object into the array
181177
$childArr['menu'] = $child;
182178
unset($childArr['id']);
183179

184180
// recurse down and ultimately refresh the parent
185181
$this->restoreBranchFromNestedArray($childArr);
186-
$parent->refresh();
187182
}
188183
}
189184

0 commit comments

Comments
 (0)