MenuTreeStorage::saveRecursive

protected MenuTreeStorage::saveRecursive($id, &$children, &$links)

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 811

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]);
}
doc_Drupal
2016-10-29 09:27:42
Comments
Leave a Comment

Please login to continue.