From 7a5d5cdd09a301c965b44651df77f6efde211341 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Sat, 16 Oct 2021 17:09:57 +0100 Subject: [PATCH] Issue #3227370 by pfrenssen: Toolbar menu theme override omits the 'menu_name' variable (cherry picked from commit 117db6f91b7272e63d13f48bacd5b8ff0a42929c) --- .../tests/modules/toolbar_test/toolbar_test.module | 11 +++++++++++ core/modules/toolbar/toolbar.module | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/core/modules/toolbar/tests/modules/toolbar_test/toolbar_test.module b/core/modules/toolbar/tests/modules/toolbar_test/toolbar_test.module index 1f919a1e0b3..cbc014054d3 100644 --- a/core/modules/toolbar/tests/modules/toolbar_test/toolbar_test.module +++ b/core/modules/toolbar/tests/modules/toolbar_test/toolbar_test.module @@ -48,3 +48,14 @@ function toolbar_test_toolbar() { return $items; } + +/** + * Implements hook_preprocess_HOOK(). + */ +function toolbar_test_preprocess_menu(&$variables) { + // All the standard hook_theme variables should be populated when the + // Toolbar module is rendering a menu. + foreach (['menu_name', 'items', 'attributes'] as $variable) { + $variables[$variable]; + } +} diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module index 483a30b76ae..5451dcb7515 100644 --- a/core/modules/toolbar/toolbar.module +++ b/core/modules/toolbar/toolbar.module @@ -41,7 +41,7 @@ function toolbar_theme($existing, $type, $theme, $path) { ]; $items['menu__toolbar'] = [ 'base hook' => 'menu', - 'variables' => ['items' => [], 'attributes' => []], + 'variables' => ['menu_name' => NULL, 'items' => [], 'attributes' => []], ]; return $items;