diff --git a/core/includes/menu.inc b/core/includes/menu.inc
index d8dab77..bb8ea49 100644
--- a/core/includes/menu.inc
+++ b/core/includes/menu.inc
@@ -242,48 +242,6 @@ function _menu_link_translate(&$item) {
}
/**
- * Implements template_preprocess_HOOK() for theme_menu_tree().
- */
-function template_preprocess_menu_tree(&$variables) {
- $variables['tree'] = $variables['tree']['#children'];
-}
-
-/**
- * Returns HTML for a wrapper for a menu sub-tree.
- *
- * @param $variables
- * An associative array containing:
- * - tree: An HTML string containing the tree's items.
- *
- * @see template_preprocess_menu_tree()
- * @ingroup themeable
- */
-function theme_menu_tree($variables) {
- return '
';
-}
-
-/**
- * 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']);
- }
- $element['#localized_options']['set_active_class'] = TRUE;
- $output = l($element['#title'], $element['#href'], $element['#localized_options']);
- return '' . $output . $sub_menu . "\n";
-}
-
-/**
* Returns HTML for a single local task link.
*
* @param $variables
diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 52ce316..c380563 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -2692,11 +2692,9 @@ function drupal_common_theme() {
'template' => 'pager',
),
// From menu.inc.
- 'menu_link' => array(
- 'render element' => 'element',
- ),
- 'menu_tree' => array(
- 'render element' => 'tree',
+ 'menu' => array(
+ 'variables' => array('items' => []),
+ 'template' => 'menu',
),
'menu_local_task' => array(
'render element' => 'element',
diff --git a/core/lib/Drupal/Core/Cache/DatabaseBackend.php b/core/lib/Drupal/Core/Cache/DatabaseBackend.php
index 4c431dc..13094b7 100644
--- a/core/lib/Drupal/Core/Cache/DatabaseBackend.php
+++ b/core/lib/Drupal/Core/Cache/DatabaseBackend.php
@@ -53,6 +53,9 @@ public function __construct(Connection $connection, $bin) {
* Implements Drupal\Core\Cache\CacheBackendInterface::get().
*/
public function get($cid, $allow_invalid = FALSE) {
+ if ($this->bin == 'render') {
+ return NULL;
+ }
$cids = array($cid);
$cache = $this->getMultiple($cids, $allow_invalid);
return reset($cache);
diff --git a/core/lib/Drupal/Core/Template/TwigExtension.php b/core/lib/Drupal/Core/Template/TwigExtension.php
index 4cb31ca..620bf6e 100644
--- a/core/lib/Drupal/Core/Template/TwigExtension.php
+++ b/core/lib/Drupal/Core/Template/TwigExtension.php
@@ -29,6 +29,7 @@ public function getFunctions() {
new \Twig_SimpleFunction('url', 'url'),
// This function will receive a renderable array, if an array is detected.
new \Twig_SimpleFunction('render_var', 'twig_render_var'),
+ new \Twig_SimpleFunction('link_path', 'l'),
);
}
diff --git a/core/modules/menu_link/lib/Drupal/menu_link/MenuTree.php b/core/modules/menu_link/lib/Drupal/menu_link/MenuTree.php
index 24a531f..85528ed 100644
--- a/core/modules/menu_link/lib/Drupal/menu_link/MenuTree.php
+++ b/core/modules/menu_link/lib/Drupal/menu_link/MenuTree.php
@@ -14,6 +14,7 @@
use Drupal\Core\Entity\Query\QueryFactory;
use Drupal\Core\KeyValueStore\StateInterface;
use Drupal\Core\Language\LanguageManagerInterface;
+use Drupal\Core\Template\Attribute;
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
use Symfony\Component\HttpFoundation\RequestStack;
@@ -362,7 +363,7 @@ public function renderMenu($menu_name) {
/**
* {@inheritdoc}
*/
- public function renderTree($tree) {
+ public function renderTree($tree, $level = 0) {
$build = array();
$items = array();
$menu_name = $tree ? end($tree)['link']['menu_name'] : '';
@@ -396,27 +397,42 @@ public function renderTree($tree) {
}
// Allow menu-specific theme overrides.
- $element['#theme'] = 'menu_link__' . strtr($data['link']['menu_name'], '-', '_');
- $element['#attributes']['class'] = $class;
- $element['#title'] = $data['link']['title'];
+ $element = array();
+ $element['attributes'] = new Attribute();
+ $element['attributes']['class'] = $class;
+ $element['title'] = $data['link']['title'];
// @todo Use route name and parameters to generate the link path, unless
// it is external.
- $element['#href'] = $data['link']['link_path'];
- $element['#localized_options'] = !empty($data['link']['localized_options']) ? $data['link']['localized_options'] : array();
- $element['#below'] = $data['below'] ? $this->renderTree($data['below']) : $data['below'];
- $element['#original_link'] = $data['link'];
+ if ($data['link']->route_name) {
+ $path = \Drupal::urlGenerator()->getPathFromRoute($data['link']->route_name, $data['link']->route_parameters);
+ }
+ else {
+ $path = $data['link']->link_path;
+ }
+ $element['href'] = $path;
+ $element['localized_options'] = !empty($data['link']['localized_options']) ? $data['link']['localized_options'] : array();
+ $element['localized_options']['set_active_class'] = TRUE;
+ $element['below'] = $data['below'] ? $this->renderTree($data['below'], $level + 1) : $data['below'];
+ $element['original_link'] = $data['link'];
// Index using the link's unique mlid.
$build[$data['link']['mlid']] = $element;
+
+ }
+
+ if (!$build) {
+ return array();
}
- if ($build) {
+ elseif ($level == 0) {
+ $build_copy = $build;
+ $build = array();
// Make sure drupal_render() does not re-order the links.
$build['#sorted'] = TRUE;
// Add the theme wrapper for outer markup.
// Allow menu-specific theme overrides.
- $build['#theme_wrappers'][] = 'menu_tree__' . strtr($menu_name, '-', '_');
+ $build['#theme'] = 'menu__' . strtr($menu_name, '-', '_');
+ $build['#items'] = $build_copy;
// Set cache tag.
- $menu_name = $data['link']['menu_name'];
- $build['#cache']['tags']['menu'][$menu_name] = $menu_name;
+ #$build['#cache']['tags']['menu'][$menu_name] = $menu_name;
}
return $build;
diff --git a/core/modules/system/templates/menu.html.twig b/core/modules/system/templates/menu.html.twig
new file mode 100644
index 0000000..29c8e28
--- /dev/null
+++ b/core/modules/system/templates/menu.html.twig
@@ -0,0 +1,25 @@
+{#
+/**
+ * @file
+ * Default theme implementation to display a menu.
+#}
+{% import _self as menus %}
+
+
+{% macro menu_links(items, menu_level) %}
+ {% import _self as menus %}
+ {% if items %}
+
+ {% endif %}
+{% endmacro %}