load('footer', $menu_tree_parameters); $cc = 0; foreach($tree as $menu){ $title = $menu->link->getTitle(); $urlObject = $menu->link->getUrlObject(); $url = $urlObject->toString(); $weight = $menu->link->getWeight(); $enabled = $menu->link->isEnabled(); if($enabled) { $menu_array[$cc]['title'] = $title; $menu_array[$cc]['url'] = $url; $menu_array[$cc]['weight'] = $weight; $cc++; } } usort($menu_array, function($a, $b) { return $a['weight'] - $b['weight']; }); return array( '#theme' => 'footer', '#menu_array' => $menu_array, '#attached' => array( 'library' => array( 'footer/footer', ), ), ); } }