SimpleMobileMenuMenuLinkTree.php in Simple Mobile Menu 8.2
File
src/Menu/SimpleMobileMenuMenuLinkTree.php
View source
<?php
namespace Drupal\simple_mobile_menu\Menu;
use Drupal\Core\Menu\MenuLinkTree;
class SimpleMobileMenuMenuLinkTree extends MenuLinkTree {
public function build(array $tree, $level = 0) {
if ($level == 0) {
if (!$tree) {
return [];
}
$build = parent::build($tree, $level);
$first_link = reset($tree)->link;
$menu_name = $first_link
->getMenuName();
$build['#menu_name'] = $menu_name;
$build['#theme'] = 'menu__simple_mobile_menu__' . strtr($menu_name, '-', '_');
return $build;
}
else {
return parent::build($tree, $level);
}
}
}