function menu_link_delete_multiple

Deletes multiple menu links.

Parameters

array $mlids: An array of menu link IDs.

bool $force: (optional) Forces deletion. Internal use only, setting to TRUE is discouraged. Defaults to FALSE.

bool $prevent_reparenting: (optional) Disables the re-parenting logic from the deletion process. Defaults to FALSE.

7 calls to menu_link_delete_multiple()
LinksTest::createLinkHierarchy in drupal/core/modules/system/lib/Drupal/system/Tests/Menu/LinksTest.php
Create a simple hierarchy of links.
MenuDeleteMenuForm::submitForm in drupal/core/modules/menu/lib/Drupal/menu/Form/MenuDeleteMenuForm.php
Form submission handler.
menu_delete_links in drupal/core/includes/menu.inc
Deletes all links for a menu.
menu_link_delete in drupal/core/modules/menu_link/menu_link.module
Deletes a menu link.
menu_link_maintain in drupal/core/modules/menu_link/menu_link.module
Inserts, updates, enables, disables, or deletes an uncustomized menu link.

... See full list

File

drupal/core/modules/menu_link/menu_link.module, line 83
Enables users to create menu links.

Code

function menu_link_delete_multiple(array $mlids, $force = FALSE, $prevent_reparenting = FALSE) {
  if (!$mlids) {

    // If no IDs or invalid IDs were passed, do nothing.
    return;
  }
  $controller = Drupal::entityManager()
    ->getStorageController('menu_link');
  if (!$force) {
    $entity_query = Drupal::entityQuery('menu_link');
    $group = $entity_query
      ->orConditionGroup()
      ->condition('module', 'system', '<>')
      ->condition('updated', 0, '<>');
    $entity_query
      ->condition('mlid', $mlids, 'IN');
    $entity_query
      ->condition($group);
    $result = $entity_query
      ->execute();
    $entities = $controller
      ->load($result);
  }
  else {
    $entities = $controller
      ->load($mlids);
  }
  $controller
    ->preventReparenting($prevent_reparenting);
  $controller
    ->delete($entities);
}