diff --git a/core/includes/menu.inc b/core/includes/menu.inc
index 68c3c54..e8cf9b5 100644
--- a/core/includes/menu.inc
+++ b/core/includes/menu.inc
@@ -7,7 +7,6 @@
use Drupal\Component\Utility\String;
use Drupal\Core\Render\Element;
-use Drupal\Core\Template\Attribute;
/**
* @defgroup menu Menu and routing system
@@ -371,18 +370,18 @@ function theme_menu_link(array $variables) {
}
/**
- * Returns HTML for a single local task link.
+ * Prepares variables for single local task link templates.
*
- * @param $variables
+ * Default template: menu-local-task.html.twig.
+ *
+ * @param array $variables
* An associative array containing:
* - element: A render element containing:
* - #link: A menu link array with 'title', 'href', and 'localized_options'
* keys.
* - #active: A boolean indicating whether the local task is active.
- *
- * @ingroup themeable
*/
-function theme_menu_local_task($variables) {
+function template_preprocess_menu_local_task(&$variables) {
$link = $variables['element']['#link'];
$link += array(
'localized_options' => array(),
@@ -392,6 +391,7 @@ function theme_menu_local_task($variables) {
if (!empty($variables['element']['#active'])) {
// Add text to indicate active tab for non-visual users.
$active = '' . t('(active tab)') . '';
+ $variables['attributes']['class'] = array('active');
// If the link does not contain HTML already, String::checkPlain() it now.
// After we set 'html'=TRUE the link will not be sanitized by l().
@@ -403,29 +403,36 @@ function theme_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'],
+ );
}
-
- return '
' . $a_tag . '
';
}
/**
- * Returns HTML for a single local action link.
+ * Prepares variables for single local action link templates.
*
- * @param $variables
+ * Default template: menu-local-action.html.twig.
+ *
+ * @param array $variables
* An associative array containing:
* - element: A render element containing:
* - #link: A menu link array with 'title', 'href', and 'localized_options'
* keys.
- *
- * @ingroup themeable
*/
-function theme_menu_local_action($variables) {
+function template_preprocess_menu_local_action(&$variables) {
$link = $variables['element']['#link'];
$link += array(
'href' => '',
@@ -436,19 +443,24 @@ function theme_menu_local_action($variables) {
$link['localized_options']['attributes']['class'][] = 'button-action';
$link['localized_options']['set_active_class'] = TRUE;
- $output = '
';
+ $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'])) {
- $output .= 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 {
- $output .= l($link['title'], $link['href'], $link['localized_options']);
+ $variables['link']['#href'] = $link['href'];
}
- $output .= "
";
-
- return $output;
}
/**
@@ -641,36 +653,6 @@ function menu_local_tabs() {
}
/**
- * Returns HTML for primary and secondary local tasks.
- *
- * @param $variables
- * An associative array containing:
- * - primary: (optional) An array of local tasks (tabs).
- * - secondary: (optional) An array of local tasks (tabs).
- *
- * @ingroup themeable
- * @see menu_local_tasks()
- */
-function theme_menu_local_tasks(&$variables) {
- $output = '';
-
- if (!empty($variables['primary'])) {
- $variables['primary']['#prefix'] = '