47 $item = array_replace($itemDefault, $item);
49 if ($context->menuIsActive($item[
'id'])) {
50 $item[
'active'] =
true;
53 if (!isset($item[
'class'])) {
54 $item[
'class'] =
'--item-' . preg_replace(
'/[^a-z0-9 ]/i',
'-', $item[
'id']);
58 if (!empty($item[
'override'])) {
59 $menu .= $item[
'override'];
60 } elseif (!empty($item[
'children'])) {
62 $haveChildActive =
false;
64 foreach ($item[
'children'] as $child) {
65 $item = array_replace($itemDefault, $item);
66 '@phan-var-force array{id:string,rank:int,url:string,name:string,group:string,override?:int<0,1>,active?:bool,separator?:bool} $child';
68 if (!empty($child[
'separator'])) {
69 $menuChildren .=
'<li role="separator" class="divider"></li>';
72 if ($context->menuIsActive($child[
'id'])) {
73 $child[
'active'] =
true;
74 $haveChildActive =
true;
77 if (!empty($child[
'children'])) {
78 $menuChildren .=
"\n\r" .
'<!-- print sub menu -->' .
"\n\r";
79 $menuChildren .=
getNavItem($child, $deep + 1);
80 $menuChildren .=
"\n\r" .
'<!-- print sub menu -->' .
"\n\r";
82 $menuChildren .=
'<li class="dropdown-item '.$item[
'class'].
'" data-deep="' . $deep .
'" ><a href="' . $child[
'url'] .
'" class="' . (!empty($child[
'active']) ?
'active' :
'') .
'" ">' . $child[
'name'] .
'</a></li>';
87 if ($haveChildActive || $item[
'active']) {
91 $menu .=
'<li data-deep="' . $deep .
'" class="'.$item[
'class'].
' dropdown ' . ($deep > 0 ?
'dropdown-item dropdown-submenu' :
'nav-item') .
' ' . $active .
'">';
92 $menu .=
'<a href="#" class="' . ($deep > 0 ?
'' :
'nav-link') .
' dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">' . $item[
'name'] .
' <span class="caret"></span></a>';
93 $menu .=
'<ul class="dropdown-menu ">' . $menuChildren .
'</ul>';
96 $menu .=
'<li data-deep="' . $deep .
'" class="'.$item[
'class'].
' ' . ($deep > 0 ?
'dropdown-item' :
'nav-item ') .
' ' . ($item[
'active'] ?
'active' :
'') .
'"><a href="' . $item[
'url'] .
'" class="' . ($deep > 0 ?
'' :
'nav-link') .
'" >' . $item[
'name'] .
'</a></li>';
static getInstance()
Singleton method to create one instance of this object.