You are here

public static function WeMegaMenuBuilder::sortMenuDeep in Drupal Mega Menu 8.x

Same name and namespace in other branches
  1. 8 src/WeMegaMenuBuilder.php \Drupal\we_megamenu\WeMegaMenuBuilder::sortMenuDeep()

Sort list child menu.

Parameters

string $menu: Public static function sortMenuDeep menu.

Return value

array Public static function sortMenuDeep array.

1 call to WeMegaMenuBuilder::sortMenuDeep()
WeMegaMenuBuilder::getMenuTreeOrder in src/WeMegaMenuBuilder.php
Get menu tree sorted by weight ascending.

File

src/WeMegaMenuBuilder.php, line 110

Class

WeMegaMenuBuilder

Namespace

Drupal\we_megamenu

Code

public static function sortMenuDeep($menu) {
  if (is_array($menu)) {
    $menu = self::sortMenu($menu);
    foreach ($menu as $key_item => $item) {
      if (isset($item['subtree'])) {
        $menu[$key_item]['subtree'] = self::sortMenuDeep($item['subtree']);
      }
    }
    return $menu;
  }
  return [];
}