function simple_megamenu_theme_suggestions_menu_alter in Simple Mega Menu 8
Same name and namespace in other branches
- 2.0.x simple_megamenu.module \simple_megamenu_theme_suggestions_menu_alter()
Implements hook_theme_suggestions_HOOK_alter().
File
- ./
simple_megamenu.module, line 87 - Contains simple_megamenu.module.
Code
function simple_megamenu_theme_suggestions_menu_alter(array &$suggestions, array $variables) {
if (!isset($variables['menu_name'])) {
return;
}
$menu_name = $variables['menu_name'];
$menu_name_sanitized = strtr($menu_name, '-', '_');
/* @var \Drupal\simple_megamenu\SimpleMegaMenuHelperInterface $simple_megamenu_helper */
$simple_megamenu_helper = \Drupal::service('simple_megamenu.helper');
if ($simple_mega_menu_types = $simple_megamenu_helper
->getMegaMenuTypeWhichTargetMenu($menu_name)) {
// We add the default suggestion removed in hook_preprocess_block.
$suggestions[] = 'menu__' . $menu_name_sanitized;
// And now our own suggestions.
$suggestions[] = 'menu__simple_megamenu';
$suggestions[] = 'menu__simple_megamenu__' . $menu_name_sanitized;
$mega_menu_type_id = implode('_', array_keys($simple_mega_menu_types));
$suggestions[] = 'menu__simple_megamenu__' . $menu_name_sanitized . '__' . $mega_menu_type_id;
}
}