/**
* {@inheritdoc}
*/
public function rebuild(array
$definitions) { $links =
[];
$children =
[];
$top_links =
[];
// Fetch the list of existing menus, in case some are not longer populated
// after the rebuild.
$before_menus =
$this->
getMenuNames();
if ($definitions) { foreach ($definitions as $id =>
$link) { // Flag this link as discovered, i.e. saved via rebuild().
$link['discovered'
] = 1;
// Note: The parent we set here might be just stored in the {menu_tree}
// table, so it will not end up in $top_links. Therefore the later loop
// on the orphan links, will handle those cases.
if (!
empty($link['parent'
])) { $children[$link['parent'
]][$id] =
$id;
} else {