diff --git a/core/includes/menu.inc b/core/includes/menu.inc index 1a03151..1b1a52a 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -868,7 +868,7 @@ function menu_tail_load($arg, &$map, $index) { * $item['route_parameters'] is unserialized if needed. * $item['options'] is unserialized and copied to $item['localized_options']. */ -function _menu_link_prepare(&$item) { +function _menu_link_translate(&$item) { if (!is_array($item['options'])) { $item['options'] = (array) unserialize($item['options']); } @@ -888,7 +888,7 @@ function _menu_link_prepare(&$item) { } // menu_tree_check_access() may set this ahead of time for links to nodes. if (!isset($item['access'])) { - $item['access'] = Drupal::getContainer()->get('access_manager')->checkNamedRoute($item['route_name'], $item['route_parameters'], \Drupal::currentUser()); + $item['access'] = \Drupal::getContainer()->get('access_manager')->checkNamedRoute($item['route_name'], $item['route_parameters'], \Drupal::currentUser()); } } @@ -896,7 +896,7 @@ function _menu_link_prepare(&$item) { // options array. For performance reasons we only invoke this hook if the link // has the 'alter' flag set in the options array. if (!empty($item['options']['alter'])) { - drupal_alter('prepared_menu_link', $item); + drupal_alter('translated_menu_link', $item, $map); } } @@ -1052,6 +1052,7 @@ function menu_tree_output($tree) { } } + $router_item = menu_get_item(); $num_items = count($items); foreach ($items as $i => $data) { $class = array(); @@ -1082,8 +1083,12 @@ function menu_tree_output($tree) { // Allow menu-specific theme overrides. $element['#theme'] = 'menu_link__' . strtr($data['link']['menu_name'], '-', '_'); $element['#attributes']['class'] = $class; - $element['link'] = $data['link']->build(); - $element['below'] = $data['below'] ? menu_tree_output($data['below']) : $data['below']; + $element['#title'] = $data['link']['title']; + // @todo Use route name and parameters to generate the link path, unless + // it is external. + $element['#href'] = $data['link']['link_path']; + $element['#localized_options'] = !empty($data['link']['localized_options']) ? $data['link']['localized_options'] : array(); + $element['#below'] = $data['below'] ? menu_tree_output($data['below']) : $data['below']; $element['#original_link'] = $data['link']; // Index using the link's unique mlid. $build[$data['link']['mlid']] = $element; @@ -1521,7 +1526,7 @@ function _menu_tree_check_access(&$tree) { $new_tree = array(); foreach ($tree as $key => $v) { $item = &$tree[$key]['link']; - _menu_link_prepare($item); + _menu_link_translate($item); if ($item['access'] || ($item['in_active_trail'] && strpos($item['href'], '%') !== FALSE)) { if ($tree[$key]['below']) { _menu_tree_check_access($tree[$key]['below']); @@ -1638,10 +1643,10 @@ function theme_menu_link(array $variables) { $element = $variables['element']; $sub_menu = ''; - if ($element['below']) { - $sub_menu = drupal_render($element['below']); + if ($element['#below']) { + $sub_menu = drupal_render($element['#below']); } - $output = drupal_render($element['link']); + $output = l($element['#title'], $element['#href'], $element['#localized_options']); return '' . $output . $sub_menu . "\n"; } diff --git a/core/modules/menu_link/menu_link.api.php b/core/modules/menu_link/menu_link.api.php index e7b3dd7..2541eb5 100644 --- a/core/modules/menu_link/menu_link.api.php +++ b/core/modules/menu_link/menu_link.api.php @@ -11,9 +11,9 @@ */ /** - * Alter a menu link after it has been prepared and before it is rendered. + * Alter a menu link after it has been translated and before it is rendered. * - * This hook is invoked from _menu_link_prepare() after a menu link has been + * This hook is invoked from _menu_link_translate() after a menu link has been * translated; i.e., after the user access to the link's target page has * been checked. It is only invoked if $menu_link['options']['alter'] has been * set to a non-empty value (e.g. TRUE). This flag should be set using @@ -31,7 +31,7 @@ * * @see hook_menu_link_alter() */ -function hook_prepared_menu_link_alter(\Drupal\menu_link\Entity\MenuLink &$menu_link, $map) { +function hook_translated_menu_link_alter(\Drupal\menu_link\Entity\MenuLink &$menu_link, $map) { if ($menu_link->href == 'devel/cache/clear') { $menu_link->localized_options['query'] = drupal_get_destination(); } diff --git a/core/modules/system/lib/Drupal/system/Controller/SystemController.php b/core/modules/system/lib/Drupal/system/Controller/SystemController.php index 7b560dc..6145a11 100644 --- a/core/modules/system/lib/Drupal/system/Controller/SystemController.php +++ b/core/modules/system/lib/Drupal/system/Controller/SystemController.php @@ -85,7 +85,7 @@ public function overview() { if (!empty($result)) { $menu_links = $menu_link_storage->loadMultiple($result); foreach ($menu_links as $item) { - _menu_link_prepare($item); + _menu_link_translate($item); if (!$item['access']) { continue; } diff --git a/core/modules/system/lib/Drupal/system/SystemManager.php b/core/modules/system/lib/Drupal/system/SystemManager.php index 5637ff6..9d5e910 100644 --- a/core/modules/system/lib/Drupal/system/SystemManager.php +++ b/core/modules/system/lib/Drupal/system/SystemManager.php @@ -207,7 +207,7 @@ public function getAdminBlock($item) { $content = array(); $menu_links = $this->menuLinkStorage->loadByProperties(array('plid' => $item['mlid'], 'menu_name' => $item['menu_name'], 'hidden' => 0)); foreach ($menu_links as $link) { - _menu_link_prepare($link); + _menu_link_translate($link); if ($link['access']) { // Prepare for sorting as in function _menu_tree_check_access(). // The weight is offset so it is always positive, with a uniform 5-digits. diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php index ab55143..91f63d9 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php @@ -302,6 +302,7 @@ protected function doTestMenuGetItemNoAncestors() { */ protected function doTestMenuSetItem() { $item = menu_get_item('test-page'); + debug($item); $this->assertEqual($item['path'], 'test-page', "Path from menu_get_item('test-page') is equal to 'test-page'", 'menu'); diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 337addc..3dd5ab1 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -3043,19 +3043,19 @@ function system_get_module_admin_tasks($module, $info) { $links = array(); $menu_links = entity_get_controller('menu_link')->loadModuleAdminTasks(); foreach ($menu_links as $link) { - _menu_link_prepare($link); + _menu_link_translate($link); if ($link['access']) { - $links[$link['router_path']] = $link; + $links[$link['machine_name']] = $link; } } } $admin_tasks = array(); $titles = array(); - if ($menu = module_invoke($module, 'menu')) { - foreach ($menu as $path => $item) { - if (isset($links[$path])) { - $task = $links[$path]; + if ($menu = module_invoke($module, 'default_menu_links')) { + foreach ($menu as $machine_name => $item) { + if (isset($links[$machine_name])) { + $task = $links[$machine_name]; // The link description, either derived from 'description' in // hook_menu() or customized via menu module is used as title attribute. if (!empty($task['localized_options']['attributes']['title'])) { @@ -3078,10 +3078,10 @@ function system_get_module_admin_tasks($module, $info) { } } else { - $titles[$path] = $task['title']; + $titles[$machine_name] = $task['title']; } - $admin_tasks[$path] = $task; + $admin_tasks[$machine_name] = $task; } } } diff --git a/core/modules/user/user.module b/core/modules/user/user.module index 48a405d..60038a4 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -893,9 +893,9 @@ function user_menu_breadcrumb_alter(&$active_trail, $item) { } /** - * Implements hook_prepared_menu_link_alter(). + * Implements hook_translated_menu_link_alter(). */ -function user_prepared_menu_link_alter(MenuLink &$menu_link) { +function user_translated_menu_link_alter(MenuLink &$menu_link) { // Hide the "User account" link for anonymous users. if ($menu_link->link_path == 'user' && $menu_link->module == 'system' && \Drupal::currentUser()->isAnonymous()) { $menu_link->hidden = 1; diff --git a/core/themes/seven/seven.theme b/core/themes/seven/seven.theme index 26527ff..7defd49 100644 --- a/core/themes/seven/seven.theme +++ b/core/themes/seven/seven.theme @@ -114,12 +114,13 @@ function seven_admin_block_content($variables) { $output = system_admin_compact_mode() ? '