diff --cc core/includes/menu.inc
index 51dcd9a,39e5fdb..0000000
--- a/core/includes/menu.inc
+++ b/core/includes/menu.inc
@@@ -308,69 -308,9 +308,11 @@@ use Drupal\Core\Template\Attribute
*/
/**
- * 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(),
- );
- // 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.
+ * 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'
diff --git a/core/lib/Drupal/Core/Template/TwigExtension.php b/core/lib/Drupal/Core/Template/TwigExtension.php
index 401e2c8..0294e18 100644
--- a/core/lib/Drupal/Core/Template/TwigExtension.php
+++ b/core/lib/Drupal/Core/Template/TwigExtension.php
@@ -202,14 +202,20 @@ public function getUrlFromPath($path, $options = array()) {
*
* @param string $text
* The link text for the anchor tag as a translated string.
- * @param \Drupal\Core\Url $url
- * The URL object used for the link.
+ * @param \Drupal\Core\Url|string $url
+ * The URL object or string used for the link.
*
* @return string
* An HTML string containing a link to the given url.
*/
- public function getLinkFromUrl($text, Url $url) {
- return $this->linkGenerator->generateFromUrl($text, $url);
+ public function getLinkFromUrl($text, $url) {
+ if ($url instanceof Url) {
+ return $this->linkGenerator->generateFromUrl($text, $url);
+ }
+ else {
+ // @todo Convert once https://www.drupal.org/node/2306901 is in
+ return l($text, $url);
+ }
}
/**
diff --git a/core/modules/system/templates/menu.html.twig b/core/modules/system/templates/menu.html.twig
index f24a8bba..392263b 100644
--- a/core/modules/system/templates/menu.html.twig
+++ b/core/modules/system/templates/menu.html.twig
@@ -9,7 +9,7 @@
* - attributes: HTML attributes for the menu item.
* - below: The menu item child items.
* - title: The menu link title.
- * - href: The menu link url.
+ * - url: The menu link url, instance of \Drupal\Core\Url
* - localized_options: Menu link localized options.
*
* @ingroup themeable