Page callback. Get all the available menus and menu items as a JavaScript array.
function menu_parent_options_js() {
$available_menus = array();
$menus = Drupal::request()->request
->get('menus');
if (count($menus)) {
foreach ($menus as $menu) {
$available_menus[$menu] = $menu;
}
}
$options = _menu_get_options(menu_get_menus(), $available_menus, array(
'mlid' => 0,
));
return new JsonResponse($options);
}