function menu_ui_get_menus

Same name in other branches
  1. 8.9.x core/modules/menu_ui/menu_ui.module \menu_ui_get_menus()

Return an associative array of the custom menus names.

Parameters

bool $all: (optional) If FALSE return only user-added menus, or if TRUE also include the menus defined by the system. Defaults to TRUE.

Return value

array An array with the machine-readable names as the keys, and human-readable titles as the values.

Deprecated

in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Drupal\system\Entity\Menu::loadMultiple() instead.

See also

https://www.drupal.org/node/3027453

1 call to menu_ui_get_menus()
MenuLegacyTest::testMenuUiGetMenus in core/tests/Drupal/KernelTests/Core/Menu/MenuLegacyTest.php
Tests deprecation of the menu_ui_get_menus() function.

File

core/modules/menu_ui/menu_ui.module, line 442

Code

function menu_ui_get_menus($all = TRUE) {
    @trigger_error(__FUNCTION__ . '() is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \\Drupal\\system\\Entity\\Menu::loadMultiple() instead. See https://www.drupal.org/node/3027453', E_USER_DEPRECATED);
    if ($custom_menus = Menu::loadMultiple()) {
        if (!$all) {
            $custom_menus = array_diff_key($custom_menus, menu_list_system_menus());
        }
        foreach ($custom_menus as $menu_name => $menu) {
            $custom_menus[$menu_name] = $menu->label();
        }
        asort($custom_menus);
    }
    return $custom_menus;
}

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