diff --git a/core/includes/menu.inc b/core/includes/menu.inc index b646726..639a94c 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -153,15 +153,6 @@ */ /** - * Menu type -- A "normal" menu item that's shown in menus. - * - * Normal menu items show up in the menu tree and can be moved/hidden by - * the administrator. Use this for most menu items. It is the default value if - * no menu item type is specified. - */ -define('MENU_NORMAL_ITEM', MENU_VISIBLE_IN_TREE); - -/** * Menu type -- A hidden, internal callback, typically used for API calls. * * Callbacks simply register a path so that the correct function is fired @@ -170,16 +161,6 @@ const MENU_CALLBACK = 0x0000; /** - * Menu type -- A normal menu item, hidden until enabled by an administrator. - * - * Modules may "suggest" menu items that the administrator may enable. They act - * just as callbacks do until enabled, at which time they act like normal items. - * Note for the value: 0x0010 was a flag which is no longer used, but this way - * the values of MENU_CALLBACK and MENU_SUGGESTED_ITEM are separate. - */ -define('MENU_SUGGESTED_ITEM', 0x0010); - -/** * @} End of "defgroup menu_item_types". */ @@ -1005,20 +986,6 @@ function _menu_link_save_recursive($controller, $machine_name, &$children, &$lin * An array of default menu links. */ function menu_link_get_defaults() { - $module_handler = \Drupal::moduleHandler(); - - $discovery = new YamlDiscovery('menu_links', $module_handler->getModuleDirectories()); - $all_links = array(); - foreach ($discovery->findAll() as $module => $menu_links) { - foreach ($menu_links as $machine_name => $menu_link) { - $all_links[$machine_name] = $menu_link; - $all_links[$machine_name]['machine_name'] = $machine_name; - $all_links[$machine_name]['module'] = $module; - } - } - - $module_handler->alter('menu_link_defaults', $all_links); - return $all_links; } /** @@ -1041,7 +1008,7 @@ function menu_link_rebuild_defaults() { $links = array(); $children = array(); $top_links = array(); - $all_links = menu_link_get_defaults(); + $all_links = \Drupal::service('menu_link.static')->getLinks(); if ($all_links) { foreach ($all_links as $machine_name => $link) { // For performance reasons, do a straight query now and convert to a menu diff --git a/core/modules/contact/contact.menu_links.yml b/core/modules/contact/contact.menu_links.yml index 89f0d38..b3f83bc 100644 --- a/core/modules/contact/contact.menu_links.yml +++ b/core/modules/contact/contact.menu_links.yml @@ -7,4 +7,4 @@ contact.site_page: link_title: Contact route_name: contact.site_page menu_name: footer - type: 16 + hidden: 1 diff --git a/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php b/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php index f6461c9..27ade09 100644 --- a/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php +++ b/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php @@ -781,8 +781,8 @@ private function getStandardMenuLink() { // Retrieve menu link id of the Log out menu link, which will always be on // the front page. $query = \Drupal::entityQuery('menu_link') - ->condition('module', 'system') - ->condition('link_path', 'user/logout'); + ->condition('module', 'user') + ->condition('menu_name', 'user.logout'); $result = $query->execute(); if (!empty($result)) { $mlid = reset($result); diff --git a/core/modules/menu_link/lib/Drupal/menu_link/Entity/MenuLink.php b/core/modules/menu_link/lib/Drupal/menu_link/Entity/MenuLink.php index 36705d5..abc90ec 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/Entity/MenuLink.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/Entity/MenuLink.php @@ -363,7 +363,7 @@ public function reset() { // 'menu_name' are not stored anywhere else. Since resetting a link happens // rarely and this is a one-time operation, retrieving the full set of // default menu links does little harm. - $all_links = menu_link_get_defaults(); + $all_links = \Drupal::service('menu_link.static')->getLinks(); $original = $all_links[$this->machine_name]; $original['machine_name'] = $this->machine_name; /** @var \Drupal\menu_link\MenuLinkStorageControllerInterface $storage_controller */ diff --git a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php index e6c6544..1a0bc7b 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php @@ -310,13 +310,9 @@ public function getParentFromHierarchy(EntityInterface $entity) { public function createFromDefaultLink(array $item) { // Suggested items are disabled by default. $item += array( - 'type' => MENU_NORMAL_ITEM, 'hidden' => 0, 'options' => empty($item['description']) ? array() : array('attributes' => array('title' => $item['description'])), ); - if ($item['type'] == MENU_SUGGESTED_ITEM) { - $item['hidden'] = 1; - } return $this->create($item); } diff --git a/core/modules/menu_link/lib/Drupal/menu_link/StaticMenuLinks.php b/core/modules/menu_link/lib/Drupal/menu_link/StaticMenuLinks.php index b10cbc0..29ba4dc 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/StaticMenuLinks.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/StaticMenuLinks.php @@ -48,6 +48,7 @@ public function getLinks() { } $this->moduleHandler->alter('menu_link_defaults', $all_links); + return $all_links; } diff --git a/core/modules/menu_link/menu_link.services.yml b/core/modules/menu_link/menu_link.services.yml index 5793fa0..88f5037 100644 --- a/core/modules/menu_link/menu_link.services.yml +++ b/core/modules/menu_link/menu_link.services.yml @@ -2,3 +2,6 @@ services: menu_link.tree: class: Drupal\menu_link\MenuTree arguments: ['@database', '@cache.data', '@language_manager', '@request_stack', '@entity.manager', '@entity.query', '@state'] + menu_link.static: + class: Drupal\menu_link\StaticMenuLinks + arguments: ['@module_handler'] diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php index 1dfc109..bda7efe 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php @@ -89,8 +89,8 @@ function testBreadCrumbs() { $this->assertBreadcrumb('admin/structure/menu/manage/tools', $trail); $mlid_node_add = \Drupal::entityQuery('menu_link') - ->condition('link_path', 'node/add') - ->condition('module', 'system') + ->condition('machine_name', 'node.add_page') + ->condition('module', 'node') ->execute(); $mlid_node_add = reset($mlid_node_add); $trail += array( diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php index bb82bab..30be54a 100644 --- a/core/modules/system/system.api.php +++ b/core/modules/system/system.api.php @@ -449,13 +449,6 @@ function hook_page_build(&$page) { * this menu item (as a result of other properties), then the menu link is * always expanded, equivalent to its 'always expanded' checkbox being set * in the UI. - * - type: (optional) A bitmask of flags describing properties of the menu - * item. The following two bitmasks are provided as constants in menu.inc: - * - MENU_NORMAL_ITEM: Normal menu items show up in the menu tree and can be - * moved/hidden by the administrator. - * - MENU_SUGGESTED_ITEM: Modules may "suggest" menu items that the - * administrator may enable. - * If the "type" element is omitted, MENU_NORMAL_ITEM is assumed. * - options: (optional) An array of options to be passed to l() when * generating a link from this menu item. */ diff --git a/core/modules/system/tests/modules/menu_test/menu_test.menu_links.yml b/core/modules/system/tests/modules/menu_test/menu_test.menu_links.yml index d4ad17a..9d565df 100644 --- a/core/modules/system/tests/modules/menu_test/menu_test.menu_links.yml +++ b/core/modules/system/tests/modules/menu_test/menu_test.menu_links.yml @@ -85,3 +85,6 @@ menu_test.menu-title-test.case2: menu_test.menu-title-test.case3: link_title: 'Bike sheds full of blue smurfs' route_name: menu_test.title_test_case3 +menu_test.context: + link_title: '' + route_name: menu_test.context diff --git a/core/modules/system/tests/modules/menu_test/menu_test.module b/core/modules/system/tests/modules/menu_test/menu_test.module index d758a0c..beffcc3 100644 --- a/core/modules/system/tests/modules/menu_test/menu_test.module +++ b/core/modules/system/tests/modules/menu_test/menu_test.module @@ -16,10 +16,7 @@ */ function menu_test_menu_link_defaults_alter(&$link) { $links['menu_test.menu_name_test']['menu_name'] = menu_test_menu_name(); - $links['menu_test.context'] = array( - 'link_title' => \Drupal::config('menu_test.menu_item')->get('title'), - 'route_name' => 'menu_test.context', - ); + $links['menu_test.context']['link_title'] = \Drupal::config('menu_test.menu_item')->get('title'); } /** diff --git a/core/profiles/standard/standard.install b/core/profiles/standard/standard.install index bec1107..60c6f72 100644 --- a/core/profiles/standard/standard.install +++ b/core/profiles/standard/standard.install @@ -56,7 +56,7 @@ function standard_install() { $menu_link->save(); // Enable the Contact link in the footer menu. - menu_link_maintain('system', 'enable', 'contact'); + menu_link_maintain('contact', 'enable', 'contact'); user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access site-wide contact form')); user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('access site-wide contact form'));