protected function MenuLinkManager::deleteInstance

protected MenuLinkManager::deleteInstance(MenuLinkInterface $instance, $persist)

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.

File

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

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);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Menu!MenuLinkManager.php/function/MenuLinkManager::deleteInstance/8.1.x