/** * Deletes a specific instance. * * @param \Drupal\Core\Menu\MenuLinkInterface $instance * The plugin instance to be deleted. * @param bool $persist * If TRUE, calls MenuLinkInterface::deleteLink() on the instance. * * @throws \Drupal\Component\Plugin\Exception\PluginException * If the plugin instance does not support deletion. */ 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); }
/** * Deletes a specific instance. * * @param \Drupal\Core\Menu\MenuLinkInterface $instance * The plugin instance to be deleted. * @param bool $persist * If TRUE, calls MenuLinkInterface::deleteLink() on the instance. * * @throws \Drupal\Component\Plugin\Exception\PluginException * If the plugin instance does not support deletion. */ protected function deleteInstance(MenuLinkInterface $instance, $persist) { $id = $instance->getPluginId(); if ($instance->isDeletable()) { if ($persist) { $instance->deleteLink(); } } else { throw new PluginException(String::format('Menu link plugin with ID @id does not support deletion', array('@id' => $id))); } $this->treeStorage->delete($id); }