function MenuTreeStorage::purgeMultiple

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

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