protected function MenuLinkStorageController::preDelete

Overrides DatabaseStorageController::preDelete().

Overrides DatabaseStorageController::preDelete

File

drupal/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php, line 329
Contains \Drupal\menu_link\MenuLinkStorageController.

Class

MenuLinkStorageController
Controller class for menu links.

Namespace

Drupal\menu_link

Code

protected function preDelete($entities) {

  // Nothing to do if we don't want to reparent children.
  if ($this->preventReparenting) {
    return;
  }
  foreach ($entities as $entity) {

    // Children get re-attached to the item's parent.
    if ($entity->has_children) {
      $children = $this
        ->loadByProperties(array(
        'plid' => $entity->plid,
      ));
      foreach ($children as $child) {
        $child->plid = $entity->plid;
        $this
          ->save($child);
      }
    }
  }
}