From aa7e16af637a0f95aedc1bd855111f2e3ff065bc Mon Sep 17 00:00:00 2001
From: "luke.stewart" <luke.stewart@3564081.no-reply.drupal.org>
Date: Sat, 2 May 2020 10:09:46 -0500
Subject: [PATCH] Issue #3132289 by luke.stewart: Theme suggestion links Alter
 expects class attributes

---
 bootstrap_barrio.theme | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/bootstrap_barrio.theme b/bootstrap_barrio.theme
index ac7effa..61d6bb2 100644
--- a/bootstrap_barrio.theme
+++ b/bootstrap_barrio.theme
@@ -348,6 +348,7 @@ function bootstrap_barrio_preprocess_region(&$variables) {
  * Implements hook_preprocess_HOOK() for block.html.twig.
  */
 function bootstrap_barrio_preprocess_block(&$variables) {
+  $variables['content']['#attributes']['block'] = $variables['attributes']['id'];
   // Add a clearfix class to system branding blocks.
   if ($variables['plugin_id'] == 'system_branding_block') {
     $variables['attributes']['class'][] = 'clearfix';
@@ -420,6 +421,18 @@ function bootstrap_barrio_preprocess_menu_local_task(&$variables) {
   $variables['item'] = Link::fromTextAndUrl($link['title'], $url);
 }
 
+/**
+ * Implements hook_theme_suggestions_HOOK_alter().
+ */
+function bootstrap_barrio_theme_suggestions_menu_alter(array &$suggestions, array $variables) {
+  // Taken from http://kristiankaa.dk/article/drupal8-region-specific-menu-theme-hook-suggestion
+  // bootstrap_barrio_preprocess_block(&$variables)
+  if (isset($variables['attributes']['block'])) {
+    $hook = str_replace(array('block-', '-'), array('', '_'), $variables['attributes']['block']);
+    $suggestions[] = $variables['theme_hook_original'] . '__' . $hook;
+  }
+}
+
 /**
  * Implements hook_preprocess_HOOK() for menu-local-action.html.twig.
  */
-- 
GitLab