Skip to content

Commit

Permalink
add items not bound to a root element as a root element
Browse files Browse the repository at this point in the history
  • Loading branch information
lukesnowden committed Oct 15, 2018
1 parent 209d6e3 commit e1c776e
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/LukeSnowden/Menu/MenuContainerNavigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -456,13 +456,22 @@ private function generate()
{
$this->setCurrentClass();
$roots = $this->getRoots();
$topWeight = 0;
foreach( $roots as $key => $item )
{
$roots[$key]['children'] = $this->getChildren( $item['reference'] );
$roots[$key]['class'] .= count( $roots[$key]['children'] ) > 0 ? ' has-children' : '';
$roots[$key]['class'] .= $this->rootClass( $roots[$key]['children'] );
$roots[$key]['class'] .= $this->isUrlParentClass( $item );
$roots[$key]['class'] .= $this->isUrlAncestorClass( $item );
$topWeight = max( $topWeight, $item[ 'weight' ] );
$roots[ $key ][ 'children' ] = $this->getChildren( $item[ 'reference' ] );
$roots[ $key ][ 'class' ] .= count( $roots[ $key ][ 'children' ] ) > 0 ? ' has-children' : '';
$roots[ $key ][ 'class' ] .= $this->rootClass( $roots[ $key ][ 'children' ] );
$roots[ $key ][ 'class' ] .= $this->isUrlParentClass( $item );
$roots[ $key ][ 'class' ] .= $this->isUrlAncestorClass( $item );
}
if( $this->items ) {
foreach( $this->items as $item ) {
$item[ 'weight' ] = $topWeight + 1;
$roots[] = $item;
$topWeight++;
}
}
return $roots;
}
Expand Down

0 comments on commit e1c776e

Please sign in to comment.