diff --git a/core/includes/menu.inc b/core/includes/menu.inc index bf2e58e..ac3182f 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -266,7 +266,12 @@ function template_preprocess_menu_link(&$variables) { $element = $variables['element']; $element['#localized_options']['set_active_class'] = TRUE; $variables['sub_menu'] = $element['#below']; - $variables['link'] = l($element['#title'], $element['#href'], $element['#localized_options']); + $variables['link'] = array( + '#type' => 'link', + '#title' => $element['#title'], + '#href' => $element['#href'], + '#options' => $element['#localized_options'], + ); $variables['attributes'] = $element['#attributes']; } @@ -304,15 +309,22 @@ function template_preprocess_menu_local_task(&$variables) { } $link['localized_options']['set_active_class'] = TRUE; + $variables['link'] = array( + '#type' => 'link', + '#title' => $link_text, + '#options' => $link['localized_options'], + ); + if (!empty($link['href'])) { // @todo - remove this once all pages are converted to routes. - $a_tag = l($link_text, $link['href'], $link['localized_options']); + $variables['link']['#href'] = $link['href']; } else { - $a_tag = \Drupal::l($link_text, $link['route_name'], $link['route_parameters'], $link['localized_options']); + $variables['link'] += array( + '#route_name' => $link['route_name'], + '#route_parameters' => $link['route_parameters'], + ); } - - $variables['link'] = $a_tag; } /** @@ -337,14 +349,23 @@ function template_preprocess_menu_local_action(&$variables) { $link['localized_options']['attributes']['class'][] = 'button-action'; $link['localized_options']['set_active_class'] = TRUE; + $variables['link'] = array( + '#type' => 'link', + '#title' => $link['title'], + '#options' => $link['localized_options'], + ); + // @todo Remove this check and the call to l() when all pages are converted to // routes. // @todo Figure out how to support local actions without a href properly. if ($link['href'] === '' && !empty($link['route_name'])) { - $variables['link'] = Drupal::l($link['title'], $link['route_name'], $link['route_parameters'], $link['localized_options']); + $variables['link'] += array( + '#route_name' => $link['route_name'], + '#route_parameters' => $link['route_parameters'], + ); } else { - $variables['link'] = l($link['title'], $link['href'], $link['localized_options']); + $variables['link']['#href'] = $link['href']; } } diff --git a/core/includes/theme.inc b/core/includes/theme.inc index ed0e551..05d3514 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -2624,9 +2624,11 @@ function drupal_common_theme() { ), 'menu_local_task' => array( 'render element' => 'element', + 'template' => 'menu-local-task', ), 'menu_local_action' => array( 'render element' => 'element', + 'template' => 'menu-local-action', ), 'menu_local_tasks' => array( 'variables' => array('primary' => array(), 'secondary' => array()), diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 8feb47b..435d930 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -712,6 +712,16 @@ function system_theme_suggestions_field(array $variables) { } /** + * Implements hook_theme_suggestions_HOOK(). + */ +function system_theme_suggestions_menu_link(array $variables) { + $suggestions = array(); + $element = $variables['element']; + + $suggestions[] = 'menu_link__' . $element['#original_link']['menu_name']; +} + +/** * Implements hook_stream_wrappers(). */ function system_stream_wrappers() { diff --git a/core/themes/seven/seven.theme b/core/themes/seven/seven.theme index c3e7a32..870274a 100644 --- a/core/themes/seven/seven.theme +++ b/core/themes/seven/seven.theme @@ -37,79 +37,34 @@ function seven_preprocess_page(&$variables) { } /** - * Overrides theme_menu_local_tasks(). + * Implements hook_pre_render_HOOK() for menu-local-tasks templates. * - * Returns HTML for primary and secondary local tasks. - * - **/ -function seven_menu_local_tasks(&$variables) { - $output = ''; - + * Use preprocess hook to set #attached to child elemnts + * because they will be processed by Twig and drupal_render will + * be invoked. + */ +function seven_preprocess_menu_local_tasks(array &$variables) { if (!empty($variables['primary'])) { $variables['primary']['#attached'] = array( - 'library' => array( - 'seven/drupal.nav-tabs', - ), + 'library' => array( + 'seven/drupal.nav-tabs', + ), ); - $variables['primary']['#prefix'] = '