protected function MenuTreeStorage::saveRecursive in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Menu/MenuTreeStorage.php \Drupal\Core\Menu\MenuTreeStorage::saveRecursive()
- 9 core/lib/Drupal/Core/Menu/MenuTreeStorage.php \Drupal\Core\Menu\MenuTreeStorage::saveRecursive()
Saves menu links recursively.
Parameters
string $id: The definition ID.
array $children: An array of IDs of child links collected by parent ID.
array $links: An array of all definitions keyed by ID.
File
- core/
lib/ Drupal/ Core/ Menu/ MenuTreeStorage.php, line 830
Class
- MenuTreeStorage
- Provides a menu tree storage using the database.
Namespace
Drupal\Core\MenuCode
protected function saveRecursive($id, &$children, &$links) {
if (!empty($links[$id]['parent']) && empty($links[$links[$id]['parent']])) {
// Invalid parent ID, so remove it.
$links[$id]['parent'] = '';
}
$this
->doSave($links[$id]);
if (!empty($children[$id])) {
foreach ($children[$id] as $next_id) {
$this
->saveRecursive($next_id, $children, $links);
}
}
// Remove processed link names so we can find stragglers.
unset($children[$id]);
}