public function MenuController::getParentOptions in Drupal 9
Same name and namespace in other branches
- 8 core/modules/menu_ui/src/Controller/MenuController.php \Drupal\menu_ui\Controller\MenuController::getParentOptions()
Gets all the available menus and menu items as a JavaScript array.
Parameters
\Symfony\Component\HttpFoundation\Request $request: The request of the page.
Return value
\Symfony\Component\HttpFoundation\JsonResponse The available menu and menu items.
1 string reference to 'MenuController::getParentOptions'
- menu_ui.routing.yml in core/
modules/ menu_ui/ menu_ui.routing.yml - core/modules/menu_ui/menu_ui.routing.yml
File
- core/
modules/ menu_ui/ src/ Controller/ MenuController.php, line 51
Class
- MenuController
- Returns responses for Menu routes.
Namespace
Drupal\menu_ui\ControllerCode
public function getParentOptions(Request $request) {
$available_menus = [];
if ($menus = $request->request
->get('menus')) {
foreach ($menus as $menu) {
$available_menus[$menu] = $menu;
}
}
// @todo Update this to use the optional $cacheability parameter, so that
// a cacheable JSON response can be sent.
$options = $this->menuParentSelector
->getParentSelectOptions('', $available_menus);
return new JsonResponse($options);
}