You are here

public static function MenuLinksController::deleteMenuLinks in Structure Sync 2.x

Same name and namespace in other branches
  1. 8 src/Controller/MenuLinksController.php \Drupal\structure_sync\Controller\MenuLinksController::deleteMenuLinks()

Function to delete all menu links.

1 call to MenuLinksController::deleteMenuLinks()
MenuLinksController::importMenuLinks in src/Controller/MenuLinksController.php
Function to import menu links.

File

src/Controller/MenuLinksController.php, line 409

Class

MenuLinksController
Controller for syncing menu links.

Namespace

Drupal\structure_sync\Controller

Code

public static function deleteMenuLinks(&$context) {
  $entities = StructureSyncHelper::getEntityManager()
    ->getStorage('menu_link_content')
    ->loadMultiple();
  StructureSyncHelper::getEntityManager()
    ->getStorage('menu_link_content')
    ->delete($entities);
  if (array_key_exists('drush', $context) && $context['drush'] === TRUE) {
    drush_log('Deleted all (content) menu links', 'ok');
  }
  StructureSyncHelper::logMessage('Deleted all (content) menu links');
}