function MenuLinkManager::deleteLinksInMenu

Same name in other branches
  1. 9 core/lib/Drupal/Core/Menu/MenuLinkManager.php \Drupal\Core\Menu\MenuLinkManager::deleteLinksInMenu()
  2. 10 core/lib/Drupal/Core/Menu/MenuLinkManager.php \Drupal\Core\Menu\MenuLinkManager::deleteLinksInMenu()
  3. 11.x core/lib/Drupal/Core/Menu/MenuLinkManager.php \Drupal\Core\Menu\MenuLinkManager::deleteLinksInMenu()

Overrides MenuLinkManagerInterface::deleteLinksInMenu

File

core/lib/Drupal/Core/Menu/MenuLinkManager.php, line 248

Class

MenuLinkManager
Manages discovery, instantiation, and tree building of menu link plugins.

Namespace

Drupal\Core\Menu

Code

public function deleteLinksInMenu($menu_name) {
    foreach ($this->treeStorage
        ->loadByProperties([
        'menu_name' => $menu_name,
    ]) as $plugin_id => $definition) {
        $instance = $this->createInstance($plugin_id);
        if ($instance->isDeletable()) {
            $this->deleteInstance($instance, TRUE);
        }
        elseif ($instance->isResettable()) {
            $new_instance = $this->resetInstance($instance);
            $affected_menus[$new_instance->getMenuName()] = $new_instance->getMenuName();
        }
    }
}

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