Commit 2a84a882 authored by Matt Glaman's avatar Matt Glaman Committed by Simone Wood
Browse files

Issue #3249710 by mglaman, frob, ericchew: hook_theme_suggestions_alter needs...

Issue #3249710 by mglaman, frob, ericchew: hook_theme_suggestions_alter needs to statically cache results of visible blocks
parent d85f0662
Loading
Loading
Loading
Loading
+7 −1
Changes for inc/theme.inc: 7 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -10,9 +10,15 @@
 */
function zurb_foundation_theme_suggestions_alter(&$suggestions, $variables, $hook) {
  if ($hook == 'menu' || $hook == 'block') {
    // Add cached for getVisibleBlocksPerRegion because this doesn't happen in
    // core this can be removed once
    // https://www.drupal.org/project/drupal/issues/2479459 is resolved.
    $all_blocks = &drupal_static(__FUNCTION__, []);
    if (empty($all_blocks)) {
      $all_blocks = \Drupal::service('block.repository')->getVisibleBlocksPerRegion();
    }
    // For menu blocks, check to see if the menu block is placed in an
    // off-canvas region, and if so use our custom template.
    $all_blocks = \Drupal::service('block.repository')->getVisibleBlocksPerRegion();
    $off_canvas_blocks = [];
    if (!empty($all_blocks['left_off_canvas'])) {
      $off_canvas_blocks += $all_blocks['left_off_canvas'];