$links[$id] =
$link;
} } foreach ($top_links as $id) { $this->
saveRecursive($id,
$children,
$links);
} // Handle any children we didn't find starting from top-level links.
foreach ($children as $orphan_links) { foreach ($orphan_links as $id) { // Check for a parent that is not loaded above since only internal links
// are loaded above.
$parent =
$this->
loadFull($links[$id]['parent'
]);
// If there is a parent add it to the links to be used in
// ::saveRecursive().
if ($parent) { $links[$links[$id]['parent'
]] =
$parent;
} else { // Force it to the top level.
$links[$id]['parent'
] = '';
} $this->
saveRecursive($id,
$children,
$links);
} }