You are here

protected function MenuTreeStorage::saveRecursive in Drupal 9

Same name and namespace in other branches
  1. 8 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
Rebuilds the stored menu link definitions.

File

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

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