function MenuController::getParentOptions

Same name in other branches
  1. 9 core/modules/menu_ui/src/Controller/MenuController.php \Drupal\menu_ui\Controller\MenuController::getParentOptions()
  2. 8.9.x core/modules/menu_ui/src/Controller/MenuController.php \Drupal\menu_ui\Controller\MenuController::getParentOptions()
  3. 10 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 43

Class

MenuController
Returns responses for Menu routes.

Namespace

Drupal\menu_ui\Controller

Code

public function getParentOptions(Request $request) {
    $available_menus = [];
    if ($menus = $request->request
        ->all('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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.