diff --git a/core/includes/menu.inc b/core/includes/menu.inc index c0133b1..fe4635a 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -1082,12 +1082,7 @@ 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']['#type'] = 'link'; - $element['link']['#title'] = $data['link']['title']; - $element['link']['#href'] = $data['link']['href']; - $element['link']['#route_name'] = $data['link']['route_name']; - $element['link']['#route_parameters'] = $data['link']['route_parameters']; - $element['link']['#options'] = !empty($data['link']['localized_options']) ? $data['link']['localized_options'] : array(); + $element['link'] = $data['link']->build(); $element['below'] = $data['below'] ? menu_tree_output($data['below']) : $data['below']; $element['#original_link'] = $data['link']; // Index using the link's unique mlid. 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 36ef6c1..527ba57 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 @@ -622,4 +622,21 @@ protected function findParent(EntityStorageControllerInterface $storage_controll return $parent; } + /** + * Builds and returns the renderable array for this menu link. + * + * @return array + * A renderable array representing the content of the link. + */ + public function build() { + $build = array( + '#type' => 'link', + '#title' => $this->title, + '#href' => $this->href, + '#route_name' => $this->route_name ? $this->route_name : NULL, + '#route_parameters' => $this->route_parameters, + '#options' => !empty($this->localized_options) ? $this->localized_options : array(), + ); + return $build; + } } diff --git a/core/modules/system/lib/Drupal/system/Controller/SystemController.php b/core/modules/system/lib/Drupal/system/Controller/SystemController.php index 6145a11..7b560dc 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_translate($item); + _menu_link_prepare($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 1fa6246..5637ff6 100644 --- a/core/modules/system/lib/Drupal/system/SystemManager.php +++ b/core/modules/system/lib/Drupal/system/SystemManager.php @@ -207,18 +207,19 @@ 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_translate($link); + _menu_link_prepare($link); if ($link['access']) { - // The link description, either derived from 'description' in - // hook_menu() or customized via menu module is used as title attribute. - if (!empty($link['localized_options']['attributes']['title'])) { - $link['description'] = $link['localized_options']['attributes']['title']; - unset($link['localized_options']['attributes']['title']); - } // Prepare for sorting as in function _menu_tree_check_access(). // The weight is offset so it is always positive, with a uniform 5-digits. $key = (50000 + $link['weight']) . ' ' . Unicode::strtolower($link['title']) . ' ' . $link['mlid']; - $content[$key] = $link; + $content[$key] = $link->build(); + // The link description, either derived from 'description' in + // hook_menu() or customized via menu module is used as title attribute. + // @todo - make description a separate entity property. + if (!empty($content[$key]['#options']['attributes']['title'])) { + $content[$key]['#description'] = $content[$key]['#options']['attributes']['title']; + unset($content[$key]['#options']['attributes']['title']); + } } } ksort($content); diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index f075799..771a3ab 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -347,9 +347,9 @@ function theme_admin_block_content($variables) { } $output .= '
'; foreach ($content as $item) { - $output .= '
' . l($item['title'], $item['href'], $item['localized_options']) . '
'; - if (!$compact && isset($item['description'])) { - $output .= '
' . filter_xss_admin($item['description']) . '
'; + $output .= '
' . drupal_render($item) . '
'; + if (!$compact && isset($item['#description'])) { + $output .= '
' . filter_xss_admin($item['#description']) . '
'; } } $output .= '
'; diff --git a/core/themes/seven/seven.theme b/core/themes/seven/seven.theme index 7defd49..26527ff 100644 --- a/core/themes/seven/seven.theme +++ b/core/themes/seven/seven.theme @@ -114,13 +114,12 @@ function seven_admin_block_content($variables) { $output = system_admin_compact_mode() ? '