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);
}
doc_Drupal
2016-10-29 09:27:05
Comments
Leave a Comment

Please login to continue.