Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. MenuLinkManager.php

function MenuLinkManager::deleteInstance

Deletes a specific instance.

Parameters

\Drupal\Core\Menu\MenuLinkInterface $instance: The plugin instance to be deleted.

bool $persist: If TRUE, calls MenuLinkInterface::deleteLink() on the instance.

Throws

\Drupal\Component\Plugin\Exception\PluginException If the plugin instance does not support deletion.

2 calls to MenuLinkManager::deleteInstance()
MenuLinkManager::deleteLinksInMenu in core/lib/Drupal/Core/Menu/MenuLinkManager.php
Deletes all links having a certain menu name.
MenuLinkManager::removeDefinition in core/lib/Drupal/Core/Menu/MenuLinkManager.php
Removes a single link definition from the menu tree storage.

File

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

Class

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

Namespace

Drupal\Core\Menu

Code

protected function deleteInstance(MenuLinkInterface $instance, $persist) {
    $id = $instance->getPluginId();
    if ($instance->isDeletable()) {
        if ($persist) {
            $instance->deleteLink();
        }
    }
    else {
        throw new PluginException("Menu link plugin with ID '{$id}' does not support deletion");
    }
    $this->treeStorage
        ->delete($id);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal