You are here

function simple_megamenu_preprocess_block in Simple Mega Menu 8

Same name and namespace in other branches
  1. 2.0.x simple_megamenu.module \simple_megamenu_preprocess_block()

Implements hook_preprocess_HOOK().

File

./simple_megamenu.module, line 70
Contains simple_megamenu.module.

Code

function simple_megamenu_preprocess_block(&$variables) {

  // Menus are built with #theme 'menu__MENU_NAME' form the the MenuLinkTree
  // class. We need to build menus supported by simple mega menu with the
  // default #theme menu, to be able to add suggestions in the good order.
  if (isset($variables['content']['#menu_name'])) {
    $menu_name = $variables['content']['#menu_name'];

    /** @var \Drupal\simple_megamenu\SimpleMegaMenuHelperInterface $simple_megamenu_helper */
    $simple_megamenu_helper = \Drupal::service('simple_megamenu.helper');
    if ($simple_megamenu_helper
      ->menuIsTargetedByMegaMenuType($menu_name)) {
      $variables['content']['#theme'] = 'menu';
    }
  }
}