function menu_ui_node_predelete
menu_ui_node_predelete(EntityInterface $node)
Implements hook_ENTITY_TYPE_predelete() for node entities.
File
- core/modules/menu_ui/menu_ui.module, line 169
- Allows administrators to customize the site's navigation menus.
Code
function menu_ui_node_predelete(EntityInterface $node) { // Delete all MenuLinkContent links that point to this node. /** @var \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager */ $menu_link_manager = \Drupal::service('plugin.manager.menu.link'); $result = $menu_link_manager->loadLinksByRoute('entity.node.canonical', array('node' => $node->id())); if (!empty($result)) { foreach ($result as $id => $instance) { if ($instance->isDeletable() && strpos($id, 'menu_link_content:') === 0) { $instance->deleteLink(); } } } }
© 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!modules!menu_ui!menu_ui.module/function/menu_ui_node_predelete/8.1.x