You are here

protected function MenuTreeStorage::purgeMultiple in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Menu/MenuTreeStorage.php \Drupal\Core\Menu\MenuTreeStorage::purgeMultiple()

Purges multiple menu links that no longer exist.

Parameters

array $ids: An array of menu link IDs.

1 call to MenuTreeStorage::purgeMultiple()
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 213

Class

MenuTreeStorage
Provides a menu tree storage using the database.

Namespace

Drupal\Core\Menu

Code

protected function purgeMultiple(array $ids) {
  $loaded = $this
    ->loadFullMultiple($ids);
  foreach ($loaded as $id => $link) {
    if ($link['has_children']) {
      $children = $this
        ->loadByProperties([
        'parent' => $id,
      ]);
      foreach ($children as $child) {
        $child['parent'] = $link['parent'];
        $this
          ->save($child);
      }
    }
  }
  $this
    ->doDeleteMultiple($ids);
}