public static function MenuLinksController::deleteDeletedMenuLinks in Structure Sync 8
Same name and namespace in other branches
- 2.x src/Controller/MenuLinksController.php \Drupal\structure_sync\Controller\MenuLinksController::deleteDeletedMenuLinks()
Function to delete the menu links that should be removed in this import.
1 call to MenuLinksController::deleteDeletedMenuLinks()
- MenuLinksController::importMenuLinks in src/
Controller/ MenuLinksController.php - Function to import menu links.
File
- src/
Controller/ MenuLinksController.php, line 218
Class
- MenuLinksController
- Controller for syncing menu links.
Namespace
Drupal\structure_sync\ControllerCode
public static function deleteDeletedMenuLinks($menus, &$context) {
$uuidsInConfig = [];
foreach ($menus as $menuLink) {
$uuidsInConfig[] = $menuLink['uuid'];
}
if (!empty($uuidsInConfig)) {
$query = StructureSyncHelper::getEntityQuery('menu_link_content');
$query
->condition('uuid', $uuidsInConfig, 'NOT IN');
$ids = $query
->execute();
$controller = StructureSyncHelper::getEntityManager()
->getStorage('menu_link_content');
$entities = $controller
->loadMultiple($ids);
$controller
->delete($entities);
}
if (array_key_exists('drush', $context) && $context['drush'] === TRUE) {
drush_log('Deleted menu links that were not in config', 'ok');
}
StructureSyncHelper::logMessage('Deleted menu links that were not in config');
}