function MenuTreeStorage::saveRecursive

Same name in other branches
  1. 9 core/lib/Drupal/Core/Menu/MenuTreeStorage.php \Drupal\Core\Menu\MenuTreeStorage::saveRecursive()
  2. 8.9.x core/lib/Drupal/Core/Menu/MenuTreeStorage.php \Drupal\Core\Menu\MenuTreeStorage::saveRecursive()
  3. 10 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.

1 call to MenuTreeStorage::saveRecursive()
MenuTreeStorage::rebuild in core/lib/Drupal/Core/Menu/MenuTreeStorage.php

File

core/lib/Drupal/Core/Menu/MenuTreeStorage.php, line 803

Class

MenuTreeStorage
Provides a menu tree storage using the database.

Namespace

Drupal\Core\Menu

Code

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]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.