diff --cc core/lib/Drupal/Core/CoreServiceProvider.php index 8662d64,3dc17a1..0000000 --- a/core/lib/Drupal/Core/CoreServiceProvider.php +++ b/core/lib/Drupal/Core/CoreServiceProvider.php diff --git a/core/core.services.yml b/core/core.services.yml index b015208..7772550 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -950,6 +950,7 @@ services: - { name: twig.extension, priority: 100 } calls: - [setGenerators, ['@url_generator']] + - [setLinkGenerator, ['@link_generator']] # @todo Figure out what to do about debugging functions. # @see http://drupal.org/node/1804998 twig.extension.debug: diff --git a/core/includes/menu.inc b/core/includes/menu.inc index 68c3c54..39e5fdb 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -308,69 +308,6 @@ */ /** - * Implements template_preprocess_HOOK() for theme_menu_tree(). - */ -function template_preprocess_menu_tree(&$variables) { - if (isset($variables['tree']['#heading'])) { - $variables['heading'] = $variables['tree']['#heading']; - $heading = &$variables['heading']; - // Convert a string heading into an array, using a H2 tag by default. - if (is_string($heading)) { - $heading = array('text' => $heading); - } - // Merge in default array properties into $heading. - $heading += array( - 'level' => 'h2', - 'attributes' => array(), - ); - // @todo Remove backwards compatibility for $heading['class']. - // https://www.drupal.org/node/2310341 - if (isset($heading['class'])) { - $heading['attributes']['class'] = $heading['class']; - } - // Convert the attributes array into an Attribute object. - $heading['attributes'] = new Attribute($heading['attributes']); - $heading['text'] = String::checkPlain($heading['text']); - } - - if (isset($variables['tree']['#attributes'])) { - $variables['attributes'] = new Attribute($variables['tree']['#attributes']); - } - else { - $variables['attributes'] = new Attribute(); - } - if (!isset($variables['attributes']['class'])) { - $variables['attributes']['class'] = array(); - } - $variables['attributes']['class'][] = 'menu'; - - $variables['tree'] = $variables['tree']['#children']; -} - -/** - * Returns HTML for a menu link and submenu. - * - * @param $variables - * An associative array containing: - * - element: Structured array data for a menu link. - * - * @ingroup themeable - */ -function theme_menu_link(array $variables) { - $element = $variables['element']; - $sub_menu = ''; - - if ($element['#below']) { - $sub_menu = drupal_render($element['#below']); - } - /** @var \Drupal\Core\Url $url */ - $url = $element['#url']; - $url->setOption('set_active_class', TRUE); - $output = \Drupal::linkGenerator()->generateFromUrl($element['#title'], $url); - return '' . $output . $sub_menu . "\n"; -} - -/** * Returns HTML for a single local task link. * * @param $variables diff --git a/core/lib/Drupal/Core/Menu/MenuLinkTree.php b/core/lib/Drupal/Core/Menu/MenuLinkTree.php index 62ac7ee..c4f7a72 100644 --- a/core/lib/Drupal/Core/Menu/MenuLinkTree.php +++ b/core/lib/Drupal/Core/Menu/MenuLinkTree.php @@ -231,6 +231,7 @@ public function build(array $tree, $level = 0) { $element['attributes']['class'] = $class; $element['title'] = $link->getTitle(); $element['url'] = $link->getUrlObject(); + $element['url']->setOption('set_active_class', TRUE); $element['below'] = $data->subtree ? $this->build($data->subtree, $level + 1) : array(); if (isset($data->options)) { $element['url']->setOptions(NestedArray::mergeDeep($element['url']->getOptions(), $data->options));